android.view.ViewRootImpl$CalledFromWrongThreadException
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
哎,对自己无语了,竟然一时犯了这么明显的错误,后面才发现,因此写入于此。
PS:我是在回调方法中更新UI状态,谨记!
为了解决这个问题下面有两种方法,这也是大家非常常用的。
1、Handler
private Handler mHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
};
};
2、Activity.runOnUiThread
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
}
});
以上两种方法均可用于刷新UI资源。
版权声明:125la.com站长 发表于 2019年8月15日 下午7:13。
转载请注明:android.view.ViewRootImpl$CalledFromWrongThreadException | 125啦读书导航
转载请注明:android.view.ViewRootImpl$CalledFromWrongThreadException | 125啦读书导航
相关文章
暂无评论...