android学习笔记:AndroidRuntime: java.lang.IllegalStateException: The content of the adapter has change

来源:互联网 发布:淘宝抢拍在哪 编辑:程序博客网 时间:2024/06/07 13:36

最近项目遇到一个bug,在没有通知adapter的情况下改掉了adapter的内容,但是问题的发生是在一个message传过来之后发生的,所以log里面完全没有自己代码的只言片语,在线程记录里面也没有打印出来主线程死掉的具体原因,只是说被block了。

如下:

AndroidRuntime: java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131362022, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]

后来仔细看了下log报错信息,发现虽然没有具体的代码类信息,但是有一个很关键的点:

in ListView(2131362022, class android.widget.ListView 这里面的2131362022就是编译后生成的R文件中的编号信息。将2131362022转换成16进制,然后进入R文件搜索这个16进制的数,就可以定位到具体是哪一个ListView发生了这种异常,之后的问题就迎刃而解了。

0 0
原创粉丝点击