处理The content of the adapter has changed but ListView did not receive a notification异常

istView在更新时报异常:
ERROR/AndroidRuntime(15260): 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(2131099657, class android.widget.ListView) with Adapter(class com.pocketdigi.pptheater.ListAdapter)]

网上有很多蛋疼或者治标不治本的解决方法,其实解决方法很简单:

1.如何你使用线程处理的后台数据,那么就在run方法里面用Handler将数据send出来到主线程里面的handleMessage然后再addAll或者赋值;

2.如果用的异步task,那么在onPostExecute里面去add或者赋值就ok了,注意千万不要在后台去修改类变量的方式去修改数据;

时间: 2024-09-17 22:28:40

处理The content of the adapter has changed but ListView did not receive a notification异常的相关文章

android中ListView数据刷新时的同步方法

  本文实例讲述了android中ListView数据刷新时的同步方法.分享给大家供大家参考.具体实现方法如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

listview的工作原理

       /**       * Unsorted views that can be used by the adapter as a convert view.       */       private ArrayList<View>[] mScrapViews;          private int mViewTypeCount;          private ArrayList<View> mCurrentScrap;          /**       

Android多线程任务优化1:探讨AsyncTask的缺陷

 AsyncTask还有别的缺陷,在生成listview的时候,如果adapter里面的count动态改变的话,不能使用AsyncTask,只能使用Thread+Handler,否则会出现如下错误 java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adap

android开发-android listview 数据显示bug,帮忙看一下?

问题描述 android listview 数据显示bug,帮忙看一下? 应用情景是这样的,点击底部选项卡,每个选项卡都会刷新listview,如果慢的点击一般不会出现异常,如果快速点击就会报异常,不知道什么原因,有的时候还会报这个异常:java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.support.v4.app.FragmentManagerImp

listview-SlideExpandableListView适配器改变时,未通知到Activity

问题描述 SlideExpandableListView适配器改变时,未通知到Activity 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 ListVi

Android ListView出现异常解决办法_Android

Android ListView 异常解决办法: 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: The content of the adapter has chan

Android开发中通过源码彻底理解ListView工作原理【超详细】

ListView控件是Android应用开发中原生控件中最复杂,但是又相当的重要,当应用程序要处理很多内容而且屏幕无法公完全显示的时候,ListView就可以发挥其作用了,他可以滑动手指就能把超出屏幕的部分内容移动显示到屏幕中. ListView还有一个非常神奇的功能,即使在ListView中加载非常非常多的数据,比如达到成百上千条甚至更多,ListView都不会发生OOM或者崩溃,而且随着我们手指滑动来浏览更多数据时,程序所占用的内存竟然都不会跟着增长.那么ListView是怎么实现这么神奇的

Android app主线程UI更新间歇性崩溃的问题

对App进行开发测试时,偶尔出现app崩溃的问题.日志如下: 10-25 18:44:52.935 15290-15290/com.zzq.cnblogs E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.zzq.cnblogs, PID: 15290 java.lang.IllegalStateException: The content of the adapter has changed but ListView did not re

Exception in MessageQueue callback: handleReceiveCallback

07-20 14:27:11.477: E/InputEventReceiver(7209): Exception dispatching input event. 07-20 14:27:11.477: E/MessageQueue-JNI(7209): Exception in MessageQueue callback: handleReceiveCallback 07-20 14:27:11.497: E/MessageQueue-JNI(7209): java.lang.Illegal