Android开发-- The content of the adapter has changed but ListView did not receive a notification - With AsyncTask
最近在联系开发DaysMatter时遇到一个问题:
app中使用ListView来展示所有事件,每次添加完事件后使用下面代码来更新ListView.
toDoListView.refreshDrawableState();
会出现如下错误,错误内容是讲ListView的adapter必须是在UI线程中修改,不能在后台线程中修改
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(2131034172, class android.widget.ListView)
with Adapter(class android.widget.SimpleAdapter)]
在SO上看到一个类似的问题(http://stackoverflow.com/questions/9771017/the-content-of-the-adapter-has-changed-but-listview-did-not-receive-a-notificati), 解决方法:
runOnUiThread(new Runnable() {
public void run() {
mAllResultsItem.add(item);
mAllResultsAdapter.notifyDataSetChanged();
}
});
Android开发-- The content of the adapter has changed but ListView did not receive a notification - With AsyncTask的更多相关文章
- Android The content of the adapter has changed but ListView did not receive a notification终极解决方法
这几天做一个自动扫描SD卡上所有APK文件的小工具,扫描过程中会把APK添加到LISTVIEW中显示,结果出现以下错误:(有时候触摸更新数据时候,触摸listview也会报错) E/AndroidRu ...
- 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 ...
- 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: T ...
- 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 错误的解决方案
使用了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 ...
- 【转】解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题
原文网址:http://blog.csdn.net/ueryueryuery/article/details/20607845 我写了一个Dialog,Dialog中有一个ListView,想要点Li ...
随机推荐
- Redis 学习笔记1
配置文件: 根据配置文件打开服务器: redis-server redis.conf --port 6370 redis-cli -localhost -p 6370 动态设置/获取配置选项的值 CO ...
- R语言入门 一些基本的操作
1 R的下载.安转 R有很多的版本,支持目前主流的操作系统MAC.Linux和WINDOWS系列.因为我个人是在WINDOWS下用R的,所以在这里将只介绍WINDOWS下R的下载&安装. 下载 ...
- "iostat" On Linux
CPU是一台电脑的大脑.所有的处理命令都运行在上面.I/O(输入/输出)同样扮演了一个重要角色.硬盘用于提供数据给处理器并保存CPU处理过的数据.一种衡量处理器和I/O利用率的方法是使用iostat命 ...
- vnc server on Ubuntu
Virtual Network Computing(VNC)是进行远程桌面控制的一个软件.客户端的键盘输入和鼠标操作通过网络传输到远程服务器,控制服务器的操作 (只有背景,没有菜单栏问题没有解决) ...
- vmrun命令
VMWare提供了vmrun与VIX API两种手段使用户可以通过程序对虚拟机进行控制. 在官方文档中给出了详细的说明和示例代码. vmrun:http://www.vmware. ...
- 【转】25个非常实用的jQuery/CSS3应用组件
今天分享25款功能十分强大的jQuery/CSS3应用插件,欢迎收藏. 1.jQuery水晶样式下拉导航 这是一款非常不错的jQuery多功能下拉菜单插件,菜单外观呈水晶样式,晶莹剔透,功能丰富,包含 ...
- HttpComponents-Client学习
HttpComponents-Client 学习 官方文档:http://hc.apache.org/httpcomponents-client-ga/tutorial/html/index.html ...
- Google File System 学习
摘要 Google的人设计并实现了Google File System,一个可升级的分布式文件系统,用于大的分布式数据应用.可以运行在廉价的日用硬件上,具备容错性,且为大量客户端提供了高聚合的性能. ...
- MongoDB mongod.exe或mongo.exe双击一闪就关闭
场景: 在 D:\data\ 创建 db目录之后,运行 mongod -repair 原因: 磁盘满了,没有空间了. 解决方法: 把 MongoDB\data 下的 lock 文件删掉,清理下磁盘空间 ...
- Eclipse初次java开发问题总结-2
今天对之前写的servlet程序做了个简单的性能测试发现了一些问题,经过解决这些问题没有再重现,有些问题自己确切知道原因,有的则不太确定. 1.配置文件读取问题 项目中使用.properties作为配 ...