请问大家,刚写了个线程,运行时报" android.view.ViewRootImpl$CalledFromWrongThreadException:
程序代码:
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);
应该如何解决?