Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android处理程序更新界面出错_Android_Android Handler - Fatal编程技术网

Android处理程序更新界面出错

Android处理程序更新界面出错,android,android-handler,Android,Android Handler,每次运行时,setText行都会出错,我不知道为什么 谢谢你的帮助 在设置之前,确保ReturnShow已初始化 类似于 Handler handler = new Handler() { public void handleMessage(Message msg) { super.handleMessage(msg); ReturnShow.setText(sMsg);//ReturnShow EditText ReturnShow.se

每次运行时,
setText
行都会出错,我不知道为什么

谢谢你的帮助


在设置之前,确保
ReturnShow
已初始化

类似于

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

谢谢你的回答,但是我已经在OnCreate中分配了这个值,错误仍然在ReturnShow.setText(sMsg)或ReturnShow.setSelection(ReturnShow.length())中。哦,我很愚蠢,我发现了错误,
ReturnShow=(EditText)findViewById(R.id.ResultShow)我在这里使用了不正确的ID。谢谢您的回答。
ReturnShow = (EditText)findViewById(R.id.edittext);