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那裡每次都要出錯, 是什麼原因? 附上錯誤信息
RerurnShow為null
ReturnShow = (EditText) findViewById(R.id.ResultShow);這句裡面的ID搞錯了,弄成一個非當前Activity的ID;
太粗心了