IndexOutOfBoundsException: Inconsistency detected. Invalid item position

来源:互联网 发布:什么是java servlet 编辑:程序博客网 时间:2024/05/20 23:55

RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid item position

  • cause
    使用 RecyclerView 加官方下拉刷新的时候,如果绑定的 List 对象在更新数据之前进行了 clear,而这时用户紧接着迅速上滑 RV,就会造成崩溃,而且异常不会报到你的代码上,属于RV内部错误。初次猜测是,当你 clear 了 list 之后,这时迅速上滑,而新数据还没到来,导致 RV 要更新加载下面的 Item 时候,找不到数据源了,造成 crash.
  • resovle
mNewList.clear();adapter.notifyDataSetChanged();
0 0
原创粉丝点击