The content of the adapter has changed but ListView did not receive a notification
来源:互联网 发布:电脑修复软件 编辑:程序博客网 时间:2024/06/07 16:50
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.Make sure your adapter calls notifyDataSetChanged() when its content changes.
此错误是由于绑定在Adapter的List中的数据增加了,而没有刷新ui导致的;并不是由于在网络线程(非UI线程)中调用add集合元素而导致的异常
你可以使用Timer模拟在非UI线程中调用add()集合元素,注意:add()过程中添加日志输出,在控制台中可以很正常的看到log一次次的打印;而真正导致此异常的原因是由于你在add()过程中点击或者触摸到了某一条目的时候没有刷新UI也就是没有调用Adapter的notifyDataSetChanged(),之所以有人说是由于在非UI线程add()元素才导致的异常,是因为在add()过程中调用notifyDataSetChanged(),而此方法需要在UI线程中进行
个人认为导致异常原因大概有两点
- 增加元素确实没有调用notifyDataSetChanged()
- 增加元素之后的操作太多(比如for循环嵌套,向数据库插入大量数据等待操作)并没有下一步立即执行notifyDataSetChanged();
只要在add元素之后保证notifyDataSetChanged()就不会有此异常发生了
阅读全文
0 0
- 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.
- ECNU Problem #3247 铁路修复计划(MST + 二分)
- Java知识
- 实习第一天:mybites的学习笔记(纯手打)
- linux touch
- 离散
- The content of the adapter has changed but ListView did not receive a notification
- 文件描述符fd与FILE
- Java----匿名内部类与适配器模式
- 【转】OpenCV图像的轮廓的匹配
- Python运算符和表达式
- Java配置文档
- MVP设计模式的写法
- 数据结构与算法(22)——二叉搜索树
- HTTP Status 500