Only the original thread that created a view hierarchy can touch its views
来源:互联网 发布:工程印花税怎么算法 编辑:程序博客网 时间:2024/05/22 12:19
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views
该错误是由于更新UI界面的操作放在了子线程执行。
解决方法:使用Handler将更新UI界面的操作pull到主线程中。
例如:
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
et_epc.setText(msg.obj.toString());
ArrayList<String> getEpc = handle.getAllEpc();
String readEpc = msg.obj.toString();
for(int i = 0; i < getEpc.size(); i++)
{
if(readEpc.equals(getEpc.get(i)))
{
Info info = handle.getInfoByEpc(readEpc);
et_name.setText(info.getName());
et_repair.setText(info.getRepair());
}
else
{
et_name.setText("");
et_repair.setText("");
}
}
}
};
- Only the original thread that created a view hierarchy can touch its views的相关
- 报Only the original thread that created a view hierarchy can touch its views错误解决
- Only the original thread that created a view hierarchy can touch its views错误
- 报Only the original thread that created a view hierarchy can touch its views错误解决
- 报Only the original thread that created a view hierarchy can touch its views错误解决
- Only the original thread that created a view hierarchy can touch its views错误相关
- Only the original thread that created a view hierarchy can touch its views的相关
- Only the original thread that created a view hierarchy can touch its views
- 关于Only the original thread that created a view hierarchy can touch its views的解决方案
- Only the original thread that created a view hierarchy can touch its views.
- 解决Only the original thread that created a view hierarchy can touch its views
- Only the original thread that created a view hierarchy can touch its views
- 关于Only the original thread that created a view hierarchy can touch its views的解决方案
- Only the original thread that created a view hierarchy can touch its views
- Only the original thread that created a view hierarchy can touch its views
- Only the original thread that created a view hierarchy can touch its views的解决方案
- 【异常】Only the original thread that created a view hierarchy can touch its views.
- 报错:Only the original thread that created a view hierarchy can touch its views.
- LeetCode[332] Reconstruct Itinerary
- Unicode详细介绍
- 源码-PL/SQL从入门到精通-第十五章-触发器-Part 2
- PHP 页面编码声明方法详解(header或meta)
- 文字的雕刻效果及textview限制行数
- Only the original thread that created a view hierarchy can touch its views
- 代码重构的原则
- openstack authentication api & curl
- CAD常见问题之创建一个新的键盘快捷方式
- Toast.maketext()方法解析
- android 实现一个ContentProvider对多张表进行操作
- SVM的核函数
- 11种常见的高等面向对象应用开发的设计模式(总共23种)
- dp和sp