转载请注明链接:https://blog.csdn.net/feather_wch/article/details/88294135
RecyclerView 出现的越界问题解决方案
java.lang.IndexOutOfBoundsException: Inconsistency detected. RecyclerView
版本:2019-03-07(12:30)
现象
1、RecyclerView刷新数据,虽然数据没有越界,但是报错java.lang.IndexOutOfBoundsException: Inconsistency detected.
代码:
mAdapter.notifyItemRangeChanged(0, mDataList.size());
报错:
java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder{904fae6 position=3 id=-1, oldPos=3, pLpos:-1 scrap [attachedScrap] tmpDetached no parent}
解决办法
使用notifyDataSetChanged()
更改代码为:
mAdapter.notifyDataSetChanged();