java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification

ListView UI重绘时触发layoutChildren, 此时会校验listView的mItemCount与其Adapter.getCount是否相同,不同报错。

ListView.layoutChildren:

mItemCount是在父类AdapterView中定义的,package类型

 

在两个地方mItemCount会被赋值,初始设置Adapter时:
xxAdapter.notifyDataSetChanged时:
因此一定要确保修改adapter数据和notifyDataSetChanged是coupled出现的,否则在特定时序下很容易出现上述异常。

posted on 2015-08-16 10:42  熊猫观星  阅读(1684)  评论(0编辑  收藏  举报

导航