listview 报java.lang.IllegalStateException异常的原因之一

来源:互联网 发布:手机淘宝轮播图尺寸 编辑:程序博客网 时间:2024/04/29 03:35

抛出异常信息比较明确了,就是改变listview 数据的时候,没有给通知adapter刷新

04-13 19:59:02.291 9775-9775/com.b2b E/MtaSDK: 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. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131493072, class android.widget.ListView) with Adapter(class com.b2b.activity.home.goodsmanager.GoodsManagerActivity$GoodsManagerAdapter)]
at android.widget.ListView.layoutChildren(ListView.java:1582)

解决办法,在变更listview数据的地方添加下面这一句
adapter.notifyDataSetChanged();


最后:这个问题只是个别机型会出现,为了避免挖坑,还是改变数据的时候(改变之后,立刻调用,不要等太久),调用一下吧


0 0
原创粉丝点击