程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> android-Android Handler更新界面出錯,

android-Android Handler更新界面出錯,

編輯:編程綜合問答
Android Handler更新界面出錯,
    Handler handler = new Handler() {
    public void handleMessage(Message msg) {
        super.handleMessage(msg);
        ReturnShow.setText(sMsg);//ReturnShow是一個EditText 錯誤在這裡
        ReturnShow.setSelection(ReturnShow.length());
    }
};

class ReadThread extends Thread {
    public void run() {
        sMsg = "...";
        handler.sendMessage(handler.obtainMessage());
    }
}

代碼如上, setText那裡每次都要出錯, 是什麼原因? 附上錯誤信息
CSDN移動問答

最佳回答:


RerurnShow為null
 ReturnShow = (EditText) findViewById(R.id.ResultShow);這句裡面的ID搞錯了,弄成一個非當前Activity的ID;

太粗心了

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved