最近在联系开发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的更多相关文章

  1. Android The content of the adapter has changed but ListView did not receive a notification终极解决方法

    这几天做一个自动扫描SD卡上所有APK文件的小工具,扫描过程中会把APK添加到LISTVIEW中显示,结果出现以下错误:(有时候触摸更新数据时候,触摸listview也会报错) E/AndroidRu ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. android The content of the adapter has changed but ListView did not receive a notification 错误的解决方案

    使用了AsyncTask在后台刷新适配器,并且通知ui线程更新ListView,运行时发现时不时的出现 如题 的错误, 导致程序崩溃,解决方法如下: 1.建立一个缓冲数据集,这个数据集就是填充适配器的 ...

  6. 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 ...

  7. 问题解决:The content of the adapter has changed but ListView did not receive a notification

    1. 不要在后台线程中直接调用adapter 2. 不要在后台线程中修改adapter绑定的数据 如果对adapter或者adapter绑定的数据是在线程中,加上runOnUiThread就可以了 r ...

  8. 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 ...

  9. 【转】解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题

    原文网址:http://blog.csdn.net/ueryueryuery/article/details/20607845 我写了一个Dialog,Dialog中有一个ListView,想要点Li ...

随机推荐

  1. JFinal的使用

    JFinal 中的Controller Controller是JFinal核心类之一,该类作为MVC模式中的控制器.基于JFinal的Web应用的控制器需要继承该类.Controller是定义Acti ...

  2. android 编译错误 Error:(1, 0) Plugin with id 'com.android.application' not found.

    在导入一个项目时,由于它本身的gradle版本比较高,你试用比较旧版本的gradle时就报出Plugin with id 'com.android.application' not found.的错误 ...

  3. JavaScript开源跨平台框架NativeScript

    NativeScript是一款使用JavaScript语言来构建跨平台原生移动应用的开源框架,支持iOS.Android和Windows Phone.且NativeScript的使用没有过多繁杂的要求 ...

  4. JQuery之拖拽插件

    一直以来,都对JS获取元素的位置感到非常的困惑:一会client.一会offset.一会scroll. 再加上各大浏览器之间的不兼容,唉,搞得哥晕晕乎乎的. 而很多页面效果都要用到这些位置.不得已,得 ...

  5. SCPD

    serviceType:服务类型,UPnP论坛规定为urn:schemas-upnp-org:service:serviceType: ver,serviceType:ver由用户自己设定 SCPDU ...

  6. Ogre2.1 结合OpenGL3+高效渲染

    在DX10与OpenGL3+之前,二者都是固定管线与可编程管线的混合,其中对应Ogre1.x的版本,也是结合固定与可编程管线设计.转眼到了OpenGL3+与DX10后,固定管线都被移除了,相对应着色器 ...

  7. SAP DBDI 网银接口实现案例

    在财务共享中心SSC实施中,为了提高AP和对账的效率,不可避免的需要实现和网上银行的集成.笔者为各位分析该案例如下: 为什么要上网银? 2).和SAP的无缝集成 3).直接在SAP中和银联对接 4). ...

  8. linux下压缩与打包工具——gzip, bzip2 和 tar;

    以下内容来自:阿铭http://www.apelearn.com/study_v2/chapter11.html, 把常用的写出来了:感觉可以了: 只管压缩与解压缩的工具: gzip 工具: 用的时候 ...

  9. elasticsearch系列二:索引详解(快速入门、索引管理、映射详解、索引别名)

    一.快速入门 1. 查看集群的健康状况 http://localhost:9200/_cat http://localhost:9200/_cat/health?v 说明:v是用来要求在结果中返回表头 ...

  10. e835. 使JTabbedPane中的卡片生效和失效

    By default, all new tabs are enabled, which means the user can select them. A tab can be disabled to ...