android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
来源:互联网 发布:百度云淘宝上怎么买 编辑:程序博客网 时间:2024/06/15 23:20
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views
这个错误相信大家一定不陌生,特别是刚学习android时,会引起的错误,意思是指在子线程中对UI做了操作,现在写个简单的demo:
public class MainActivity extends Activity {
private TextView textview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textview = (TextView) findViewById(R.id.textview);
new Thread(){
public void run() {
try {
Thread.sleep(1000);
textview.setText("hello");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
}
}
发现我们是在子线程中对TextView控件中添加内容,导致的错误产生!在此记录下
0 1
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- android ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hi
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a v
- ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy
- CalledFromWrongThreadException: Only the original thread that created a view
- CalledFromWrongThreadException: Only the original thread that created a view
- android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view
- android.view.viewroot$calledfromwrongthreadexception: only the original thread that created a view h
- 16-07-24 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that
- CalledFromWrongThreadException:Only the original thread that created a view hierarchy can touch its
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original
- 如何配置EditPlus编译运行Java程序?
- 第三章思维导图
- c++11 静态断言
- iOS性能优化
- 【移动开发】Android中WIFI开发总结(二)
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- 自己编写的表单验证插件
- 断电不断网——Linux的screen
- 【Cocos2d-x】实现资源热更新
- 黑马程序员——GUI 网络编程 正则
- 【 Visual C++】游戏开发笔记之二——最简单的DirectX,vc窗口的编写
- andriod bitmap使用
- Linked List Cycle (Java)
- 第四章思维导图