非主线程不能直接刷新主线程的界面,否则就会报 android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
可以使用Handler来进行处理,如:
1 Handler mHandler = new Handler()
2 {
3 public void handleMessage(Message msg)
4 {
5 if(msg.what == 0)
6 {
7 text.setText(" ");
8 }else if(msg.what == 1)
9 {
10 text.setText(tipsText);
11 }
12 }
13 };
14
15 //修改文本时调用
16
17 mHandler.sendEmptyMessage(int what);
18
19 其中XXX为消息的what值。