学习进度3

当你的程序在需要刷新某个界面UI时出现崩溃报错,并且查看LogCat信息发现下面的内容:
E/AndroidRuntime(2899): android.view.ViewRootImpl$CalledFromWrongThreadException:
Only the original thread that created a view hierarchy can touch its views.
从这句话你便可看出是刷新UI不在Activity主线程中执行导致的,解决方法:

使用主线程创建的handler执行handler.post(Runnable),在Runnable的run()方法里写更新UI的操作。

posted @ 2021-06-05 23:54  我好cai  阅读(22)  评论(0)    收藏  举报