RecyclerView notifyDataSetChanged scrolls to top position

前端 未结 8 2057
北海茫月
北海茫月 2020-12-11 00:11

when calling notifyDataSetChanged on RecyclerView it doesn\'t retain the scroll position and scrolls to top, is there any solution to retain it\'s

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 01:10

    As I am guessing, what you are doing is resetting the adapter to the RecyclerView and then calling notifyDataSetChanged().

    You need to pass only the dataList to the adapter by passing dataList in adapter method like adapter update(dataList). And in this method you can assign this list to adapter list like;

    public void update(ArrayList list){
      this.mList = list;
    }
    

提交回复
热议问题