报错:
Only the original thread that created a view hierarchy can touch its views.
在回调里面执行了listview的performitemclick的方法
mCarrierListView.performItemClick(mCarrierListView.getChildAt(0),0,mCarrierListView.getItemIdAtPosition(0));解决办法:
使用handler去做就可以了
//如果有超过一个的
if(mCarriersList.size()>0){
mHandler.post(new Runnable() {
@Override
public void run() {
mCarrierListView.performItemClick(mCarrierListView.getChildAt(0),0,mCarrierListView.getItemIdAtPosition(0));
}
});
}

本文介绍了在Android应用中遇到的一个常见错误:“Only the original thread that created a view hierarchy can touch its views.” 该错误通常发生在尝试从非UI线程更新UI组件时。文章详细解释了如何通过使用Handler来正确地调度UI更新任务到主线程,从而避免此类错误。
2776

被折叠的 条评论
为什么被折叠?



