Android错误:The content of the adapter has changed...

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。

分析:

这个错误通常是listview等控件在使用adapter适配数据时可能传入的是一个静态的list,而在adapter中直接使用=号来赋值,当外部这list被改变(如多线程操作了这个list)后没有及时的调用adapter的notifyDataSetChanged,导致下次来更新的时候报错。

解决:

在adapter中不要直接用=号来赋值,使用如下两种方法重新分配内存:

1:list.clear ,list.addall。

2:arraylist.clone。

posted @ 2015-08-29 23:07  -小城-  阅读(165)  评论(0编辑  收藏  举报