首页 > 编程语言 > 详细

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

时间:2015-08-16 12:02:48      阅读:478      评论:0      收藏:0      [点我收藏+]

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

ListView.layoutChildren:

技术分享

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

 技术分享

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

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

原文:http://www.cnblogs.com/tonybright/p/4733734.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!