閱讀108 返回首頁    go 阿裏雲 go 技術社區[雲棲]


處理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了,注意千萬不要在後台去修改類變量的方式去修改數據;

最後更新:2017-04-03 12:54:29

  上一篇:go 程序員的生產力
  下一篇:go android調用服務端的js