The content of the adapter has changed but ListView did not receive a notification异常处理

来源:互联网 发布:v7000数据迁移图文教程 编辑:程序博客网 时间:2024/05/17 19:18

        最近在做一个文件浏览器的模块,采用分步显示数据而不是等待加载完成后再一次性加载,但在编写过程中发现,在异步线程中添加Listview的Adapter的数据时,当数据未加载完成点击Listvew的Item时,会出现如下异常:

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.

        搜索相关资料后整理出解决办法如下:

        将异步线程中添加Adapter数据的代码移出至回调时添加。

注:需要注意不能让UI线程负荷太重。


0 0
原创粉丝点击