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