RecyclerView刷新数据时遇到此异常,Inconsistency detected. Invalid view holder adapter positionViewHolder{a1bbfa3 position=2 id=-1, oldPos=-1, pLpos:-1 no parent},网上查阅下说是原生bug,自定义了线性layout,重写
@Override
,结果发现还是会报红,干脆在clear数据时,public void onLayoutChildren (RecyclerView.Recycler recycler , RecyclerView.State state) {try {super .onLayoutChildren(recycler , state) ;} catch (IndexOutOfBoundsException e) {e.printStackTrace() ;}}
recycler_user.removeAllViews();就没遇到报的问题了