注册 登录
编程论坛 Android开发

请问大家,刚写了个线程,运行时报" android.view.ViewRootImpl$CalledFromWrongThreadException:

fz19910125 发布于 2013-05-30 22:24, 1649 次点击
程序代码:
Runnable runnable = new Runnable() {
        int iCount = 0;
        @Override
        public void run() {
            showTextView.setText("run:" + Integer.toString(iCount));//报这行出错
            iCount++;
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    };
出错信息:android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
通过响应Button的OnClickListener事件,创建了一个线程Thread thread = new Thread(runnable);
应该如何解决?
0 回复
1