Android错误:The content of the adapter has changed...

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。

分析:

这个错误通常是listview等控件在使用adapter适配数据时可能传入的是一个静态的list,而在adapter中直接使用=号来赋值,当外部这list被改变(如多线程操作了这个list)后没有及时的调用adapter的notifyDataSetChanged,导致下次来更新的时候报错。

解决:

在adapter中不要直接用=号来赋值,使用如下两种方法重新分配内存:

1:list.clear ,list.addall。

2:arraylist.clone。

时间: 2024-10-01 08:05:56

Android错误:The content of the adapter has changed...的相关文章

android adapter报错The content of the adapter has changed but ListView did not receive a notification.

在Android编程中使用Adapter时,偶尔会出现如下错误: 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. DDMS中的log也无法定位到准确的出错位置.检

Android报错:The content of the adapter has changed...与Channel is unrecoverably broken and will be disposed的分析与解决办法

在Android中adapter错误: 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. 分析: 这个错误通常是listview等控件在使用adapter适配数据时

android 修改listview中adapter数据时抛出异常java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification问题

近日在做项目时遇到非必现crush,具体异常信息为: // Short Msg: java.lang.IllegalStateException // Long Msg: 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 mo

Android开发教程--关于Adapter的The content of the adapter has changed问题分析

我们在做android list开发的时候,有时候会遇到类似这样的问题: 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 th

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 content of your adapter is not modified from a background thread, but only from the UI thread 原因:没有在主线程里通知.... 1.bug 出现的地方 listView.class 1487行 if (mIte

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

原文网址:http://blog.csdn.net/ueryueryuery/article/details/20607845 我写了一个Dialog,Dialog中有一个ListView,想要点ListView中的一项后,跳转到另外一个Activity去. 但在使用时,会偶尔报出下面的错误: 02-21 14:54:28.928: E/AndroidRuntime(2846): FATAL EXCEPTION: main 02-21 14:54:28.928: E/AndroidRuntime

【原创】关于Adapter的The content of the adapter has changed问题分析

关于Adapter的The content of the adapter has changed问题分析 1.问题描述 1 07-28 17:22:02.162: E/AndroidRuntime(16779): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of y

【转】关于Adapter的The content of the adapter has changed问题分析 关于Adapter的The content of the adapter has changed问题分析

原文网址:http://www.cnblogs.com/monodin/p/3874147.html 1.问题描述 1 07-28 17:22:02.162: E/AndroidRuntime(16779): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of you

The content of the adapter has changed but ListView did not receive a notification

在非Ui线程中修改ListView绑定的数据对象的问题 问题描述: 在非UI线程中修改了ListView绑定的数据对象(如List)时,如下异常: 问题分析: 在非UI线程下不能够对主线程中ListView绑定的List数据进行修改. 解决方法: 方法一:将对List中数据的修改放到主线程中. 方法二:将子线程中要更新的数据通过Handler传递到主线程中,然后在主线程中将传递过来的数据添加到ListView绑定的数据对象List中,然后同时adapter数据改变. 在这里主要介绍第二种方式: