android message 的一些小错误
分类:
IT文章
•
2024-10-27 09:35:43
android message 的一些小异常
1、java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
在Android中不允许Activity里新启动的线程访问该Activity里的UI组件,这样会导致新启动的线程无法改变UI组件的属性值。
出现java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()异常
然而,我们实际需要,在很多时候都需要异步获取数据刷新UI控件,这时候采取的方法就是Handler消息机制和AsyncTask异步任务两种解决方法。