Inconsistency detected in RecyclerView, How to change contents of RecyclerView while scrolling

前端 未结 26 2489
借酒劲吻你
借酒劲吻你 2020-12-01 00:59

I\'m using RecyclerView to display name of the items. My row contains single TextView. Item names are stored in List mItemList<

26条回答
  •  不思量自难忘°
    2020-12-01 01:53

    I figure out that, for me this exception comes when two things happens at the same time i.e.

    1) Scrolling of recyclerview

    2) data set getting changed

    So, I solved this problem by disabling the scroll till the notifydatasetchanged is called.

    leaderAdapter.notifyDataSetChanged();
    pDialog.hide();
    

    To disable the scroll, I have used a progress dialog, whose setCancelable is false.

    pDialog = new ProgressDialog(getActivity());
    pDialog.setMessage("Please wait...");
    pDialog.setCancelable(false);
    

    The trick here is to enable the scrolling only when the data set has been updated.

提交回复
热议问题