The content of the adapter has changed but ListView did not receive a notification
来源:互联网 发布:安装linux设置主机名 编辑:程序博客网 时间:2024/05/16 12:53
在Android开发过程中,使用了大量的ListView,发现这个错误偶尔会出现。特别是做压力测试的时候,不停的点击刷新,更容易出现这个错误。代码中已经使用了Adapter的notifyDataSetChanged()方法通知UI更新了,但是还是会出现这个错误。究其根本原因,还是线程之间同步的问题。比如,线程1更新了Adapter中的内容,却还没有来得及通知内容已经更新,就又有线程2更新了Adapter中的内容,这个时候如果线程1再通知内容更新,就会出现上述异常了。
在此提出一些解决办法:
对线程进行管理,如果当前Actitivty暂停了,及时停止这些线程。
数据更新后,要及时使用notifyDataSetChanged()方法通知UI,避免出现数据不一致的情况。
数据的更新,最好放在主线程中进行。这样可以使用同步数据更新与通知内容更新部分的代码。
- listview提示The content of the adapter has changed but ListView did not receive a notification
- ListView异常:The content of the adapter has changed but ListView did not receive a notification
- ListView The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification
- 解决bug:The content of the adapter has changed but ListView did not receive a notification
- The content of the adapter has changed but ListView did not receive a notification
- The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification
- .解决bug:The content of the adapter has changed but ListView did not receive a notification .
- The content of the adapter has changed but ListView did not receive a notification终极解决方法
- 处理The content of the adapter has changed but ListView did not receive a notification异常
- The content of the adapter has changed but ListView did not receive a notification错误分析
- The content of the adapter has changed but ListView did not receive a notification 异常解析
- 处理The content of the adapter has changed but ListView did not receive a notification异常
- The content of the adapter has changed but ListView did not receive a notification终极解决方法
- The content of the adapter has changed but ListView did not receive a notification
- The content of the adapter has changed but ListView did not receive a notification.
- USACO Section 5.2 Snail Trail - 很水的枚举..
- android更新到4.0后的,我xml写的界面无法在graphical layout中显示,怎么处理?
- 阻塞与非阻塞概念
- 网络搜索帮手
- 编写一个strlen函数(不用全局变量或局部变量)
- The content of the adapter has changed but ListView did not receive a notification
- 解决网站开发中ResultSet can not re-read row data for column问题
- 树形tree组件详解
- java.lang.IllegalStateException: get field slot from row 0 col -1 failed 异常错误
- 【2-SAT】POJ 3207
- 1395. Rounders
- Oracle 扫描类型
- C# Publisher/Subscriber Pattern, keyword event/delegate
- zoj 1372 ||poj 1287 Networking(最小生成树-Kruskal)