ListView:The content of the adapter has changed but ListView did not receive a notification终极解决方法
使用ListView时遇到如下的异常信息:
10-26 18:30:45.085: E/AndroidRuntime(7323): 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(2131296280, class android.widget.ListView) with Adapter(class com.souapp.appmanager.ApkListAdapter)]
其实我在listview的adapter添加完数据后,使用了handler去调用datper.notifyDataSetChanged();来通知listview显示变化结果;
虽然自己很确定没有多线程操作,但是有人说listview本来就是线程不安全的,这个不关心了,看了国外一个开发者的方法很简单。
解决方法1:
ListView.requestLayout();
Adatper.notifyDataSetChanged();
在你adpater更新前,调用listview的requestLayout(),这样做无非就是弥补数据数量不一致导致报错,虽然一个解决的好办法。
但是实际上用的时候我发现也会出问题,想了想最彻底的解决办法
彻底解决方法:
把 listview的adapter数据更新和dapter.notifyDataSetChanged()方法的调用必须同时放到单独一个线程里,报错基本是都是这个原因,有人把adapter里的数据更新了,但是 dapter.notifyDataSetChanged() 放到一个单独线程去更新,结果出现notifyDataSetChanged更新同步的问题
以上内容来自:http://blog.csdn.net/changemyself/article/details/8116670
解决更新ListView数据时出现的问题分析总结:
这个问题也不是必崩溃,低版本崩的多,高版本好像崩溃得少
ListView:The content of the adapter has changed but ListView did not receive a notification终极解决方法的更多相关文章
- Android The content of the adapter has changed but ListView did not receive a notification终极解决方法
这几天做一个自动扫描SD卡上所有APK文件的小工具,扫描过程中会把APK添加到LISTVIEW中显示,结果出现以下错误:(有时候触摸更新数据时候,触摸listview也会报错) E/AndroidRu ...
- The content of the adapter has changed but ListView did not receive a notification
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive ...
- Android 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. Make sure the co ...
- 【转】解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题
原文网址:http://blog.csdn.net/ueryueryuery/article/details/20607845 我写了一个Dialog,Dialog中有一个ListView,想要点Li ...
- Android开发-- The content of the adapter has changed but ListView did not receive a notification - With AsyncTask
最近在联系开发DaysMatter时遇到一个问题: app中使用ListView来展示所有事件,每次添加完事件后使用下面代码来更新ListView. toDoListView.refreshDrawa ...
- android The content of the adapter has changed but ListView did not receive a notification 错误的解决方案
使用了AsyncTask在后台刷新适配器,并且通知ui线程更新ListView,运行时发现时不时的出现 如题 的错误, 导致程序崩溃,解决方法如下: 1.建立一个缓冲数据集,这个数据集就是填充适配器的 ...
- java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification
ListView UI重绘时触发layoutChildren, 此时会校验listView的mItemCount与其Adapter.getCount是否相同,不同报错. ListView.layout ...
- 问题解决:The content of the adapter has changed but ListView did not receive a notification
1. 不要在后台线程中直接调用adapter 2. 不要在后台线程中修改adapter绑定的数据 如果对adapter或者adapter绑定的数据是在线程中,加上runOnUiThread就可以了 r ...
- 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 s
我出现这个问题是引用资源文件问题 helper.getView(R.id.in_pic).setBackgroundResource(item.getResourceId()); //错的helper ...
随机推荐
- Git凭证存储(简单易懂,一学就会,认真看)
今天给自己提了一个问题,当我们在github.com或者gitlab上面新建仓库,并克隆到本地,首次使用的时候,会被问及用户名密码,但是这两个信息存在哪里呢? 带着这个问题,我开始搜索,并在<P ...
- Java中创建对象的几种方式
Java中创建对象的五种方式: 作为java开发者,我们每天创建很多对象,但是我们通常使用依赖注入的方式管理系统,比如:Spring去创建对象,然而这里有很多创建对象的方法:使用New关键字.使用Cl ...
- 【ContextMenu】DataContext不自动更新
参考资料 http://www.orcode.com/article/Presentation_20147076.html 问题现象 通过绑定集合至ContextMenu的ItemsSour ...
- [Asp.net 开发系列之SignalR篇]专题五:SignalR支持的平台
SignalR支持多种服务器和客户端配置.此外,每种传输方式都有自身的要求限制:如果某种传输方式不被系统支持,SignalR能够优雅地将故障转移到其他类型的传输方式.关于SignalR所支持的传输方式 ...
- Java设计模式10:观察者模式
观察者模式 观察者模式也叫作发布-订阅模式,也就是事件监听机制.观察者模式定义了一种一对多的依赖关系,让多个观察者对象同时监听某一个主题对象,这个主题对象在状态上发生变化时,会通知所有观察者对象,使他 ...
- Apache Thrift 跨语言服务开发框架
Apache Thrift 是一种支持多种编程语言的远程服务调用框架,由 Facebook 于 2007 年开发,并于 2008 年进入 Apache 开源项目管理.Apache Thrift 通过 ...
- AlwaysON 故障处理之辅助副本磁盘空间不足
用户反馈AlwaysON辅助副本数据库查询的结果与主库不一致, 远程到服务器后发现数据库的状态显示为“未同步/可疑”, 查看数据库的日志,定位到出现错误的时间点,可以看到提示日志文件所在磁盘的“磁盘空 ...
- Azure China (4) 管理Azure China Storage Account
<Windows Azure Platform 系列文章目录> Update 2015-05-10 强烈建议使用AzCopy工具,AzCopy命令行工具,是经过优化的.高性能Azure S ...
- Hibernate SQL实际sql语句监控- p6spy+hibernate+proxool 设置
由于ORM工具的缘故,我们调试程序的时候远没有直接在程序里直接写个string的SQL简单,想当年查个sql是有多么的幸福,一行sql = "select * from ..."找 ...
- [数据库连接池二]Java数据库连接池--C3P0和JDNI.
前言:上一篇文章中讲了DBCP的用法以及实现原理, 这一篇再来说下C3P0和JDNI的用法. 1.1.C3P0数据源 C3P0是一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规 ...