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 ...
随机推荐
- Qt 菜鸟的坑 QAbstractSocket::isValid()
我曾经多次在 Qt socket 编程中使用 tcpSocket.isValid 来判断我当前的连接是否可用,最近写程序时才发现此法并不妥当. bool QAbstractSocket::isVali ...
- VC6下OpenGL 开发环境的构建外加一个简单的二维网络棋盘绘制示例
一.安装GLUT 工具包 GLUT 不是OpenGL 所必须的,但它会给我们的学习带来一定的方便,推荐安装. Windows 环境下的GLUT 本地下载地址:glut-install.zip(大小约为 ...
- SpringBoot系列九:SpringBoot服务整合(整合邮件服务、定时调度、Actuator监控)
声明:本文来源于MLDN培训视频的课堂笔记,写在这里只是为了方便查阅. 1.概念:SpringBoot 服务整合 2.背景 在进行项目开发的时候经常会遇见以下的几个问题:需要进行邮件发送.定时的任务调 ...
- python模块之psutil详解
一.psutil模块: 1.psutil是一个跨平台库(http://pythonhosted.org/psutil/)能够轻松实现获取系统运行的进程和系统利用率(包括CPU.内存.磁盘.网络等)信息 ...
- miRTarBase 数据库简介
miRTarBase 是一个手 收集的,经过实验验证过miRNA靶基因的数据库,对于每条miRNA靶基因的记录, 都会赋予1个唯一的 miRNA-target interactions (简称MTs) ...
- Dataguard中日志传输服务
之前,原本已经尝试过配置oracle实例的逻辑和物理standby结构,并且做个一些role交换操作,可是由于昨天学习rman的部分命令时没留意,误删掉了primary DB上的所有归档日志,因为原来 ...
- linq where in 排序
List<INGREDIENT> selectedIngredients = db.INGREDIENT .Where(i => model.SelectedIngredients. ...
- C# 文件过滤器filter
OpenFileDialog对话框的Filter属性说明: 首先说明一个示例,分析一下Filter属性的构成:“ Excel文件|*.xls ”,前面的“Excel文件”成为标签,是一个可读的字符串, ...
- SOFA企业应用框架
前言 从业这么多年,接触过银行的应用,Apple的应用,eBay的应用和现在阿里的应用,虽然分属于不同的公司,使用了不同的架构,但有一个共同点就是都很复杂.导致复杂性的原因有很多,如果从架构的层面看, ...
- Hbuilder MUI里面使用java.net.URL发送网络请求,操作cookie
1. 引入所需网络请求类: var URL = plus.android.importClass("java.net.URL"); var URLConnection = plus ...