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.layoutChildren:

mItemCount是在父类AdapterView中定义的,package类型

在两个地方mItemCount会被赋值,初始设置Adapter时:

xxAdapter.notifyDataSetChanged时:

因此一定要确保修改adapter数据和notifyDataSetChanged是coupled出现的,否则在特定时序下很容易出现上述异常。

时间: 2024-12-13 17:50:46

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification的相关文章

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

【转】解决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

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

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也无法定位到准确的出错位置.检

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数据改变. 在这里主要介绍第二种方式:

【原创】关于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

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开发:java.lang.IllegalStateException报错

常见于ListView列表刷新数据时,更改UI. LOG: 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无法定位到准确的出错位置.检查错误可