问题描述
- 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()); } }
解决方案
RerurnShow为null
ReturnShow = (EditText) findViewById(R.id.ResultShow);这句里面的ID搞错了,弄成一个非当前Activity的ID;
太粗心了
解决方案二:
需要在设置ReturnShow
之前对它进行初始化..
比如这样:
ReturnShow = (EditText)findViewById(R.id.edittext);
时间: 2024-11-08 20:24:16