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

ListView.layoutChildren:

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

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

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

在两个地方mItemCount会被赋值,初始设置Adapter时:
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification
xxAdapter.notifyDataSetChanged时:
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification
因此一定要确保修改adapter数据和notifyDataSetChanged是coupled出现的,否则在特定时序下很容易出现上述异常。

相关文章:

  • 2021-07-11
  • 2022-12-23
  • 2021-05-28
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
猜你喜欢
  • 2021-05-21
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2021-06-30
相关资源
相似解决方案