0
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());
    }
}

Everytime I run, the setText line will have error, I can't figure out why?

Thanks for your help.

enter image description here

mmBs
  • 8,421
  • 6
  • 38
  • 46
Miss.seven
  • 13
  • 4

1 Answers1

1

Make sure that ReturnShow is initialized before setting it..

Something like..

ReturnShow = (EditText)findViewById(R.id.edittext);
Nermeen
  • 15,883
  • 5
  • 59
  • 72
  • thanks for your answer,but I have Assign this value in OnCreate,the error is still on – Miss.seven May 14 '13 at 09:10
  • the error is in ReturnShow.setText(sMsg) or ReturnShow.setSelection(ReturnShow.length())? – Nermeen May 14 '13 at 09:13
  • oh.i'm stupid ,i found the error,`ReturnShow = (EditText) findViewById(R.id.ResultShow);` I use a incorrect ID here.thanks for your answer. – Miss.seven May 14 '13 at 09:38