一般情况下,Adapter性质的类,只要Adapter中的数据更新后没有及时调用notifyDataSetChanged() 。或者在异步工作线程中修改数据。可能就会触发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(2131558482, class android.widget.ListView) with Adapter(
class android.widget.HeaderViewListAdapter)]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(2131558482, class android.widget.ListView)
with Adapter(class android.widget.HeaderViewListAdapter)]
解决方法:就是在修改Adapter数据的时候,紧跟着调用notifyDataSetChanged() 。