我得到了getHandler一个NullPointerException,我解决不了这个问题..NullPointerException异常处理程序的Android
你能帮助我吗?我不知道错误在哪里..错误发生在相同的情况下随机。
一些代码...
final Handler mHandler = new Handler();
new Thread(new Runnable() {
public void run() {
while (mProgressStatus < 100) {
mProgressStatus = Elabora();
mHandler.post(new Runnable() {
public void run() {
progressBar1.setProgress((int) mProgressStatus);
}
});
}
if(isStopped)
{
op_ko.show();
//error in the next line
txt_status1.getHandler().post(new Runnable() {
public void run() {
txt_status1.setText(R.string.op_ko);
}
});
}
else
{
op_ok.show();
txt_status1.getHandler().post(new Runnable() {
public void run() {
txt_status1.setText(R.string.op_ok);
}
});
}
btn_stop.getHandler().post(new Runnable() {
public void run() {
btn_stop.setVisibility(View.INVISIBLE);
}
});
}
请发布完整的LogCat输出。 – bschultz 2012-03-06 21:47:23
并在代码中显示您正在为txt_status1设置处理程序的位置。最直接的可能是你永远不会设置处理程序! – robamaton 2012-03-06 21:48:44
这里是logCat:http://dl.dropbox.com/u/47137048/logcat.txt – kekko986 2012-03-06 22:10:07