RecyclerView notifyItemRangeInserted()方法報數組越界

    UncaughtException detected: java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid view holder adapter positionViewHolder

解決辦法,如果是第一次加載或下拉刷新,則使用notifyDataSetChanged刷新數據:

if (isRefresh) {
    mGoodsListAdapter.notifyDataSetChanged();
} else {
    mGoodsListAdapter.notifyItemRangeInserted(mGoodsListAdapter.getItemCount(), mRecommendDataList.size());
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章