notifyDataSetChanged() makes the list refresh and scroll jumps back to the top

前端 未结 5 1606
自闭症患者
自闭症患者 2020-11-27 05:13

I am trying to implement an endless scroll listview but when I call notifyDataSetChanged() the whole list refreshes then the scroll position goes back to the to

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 05:46

    You can do it in another way, like this

    int position = scrollView.getSelectedItemPosition();
    notifyDataSetChanged();
    scrollView.setSelection(position);
    

提交回复
热议问题