RecyclerView notifyDataSetChanged scrolls to top position

前端 未结 8 2092
北海茫月
北海茫月 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:02

    You can't scroll to position without having set the adapter first. Set your adapter first, even if your list is empty. Update your list when you get the data. Then call adapter.notifydatasetchanged() method. You can then scroll to the last position. Let me know if this answers your question or if I have to put an answer – mmmcho

提交回复
热议问题