简体   繁体   中英

How to set scroll position to top of a listview

I have a listview,I want to refresh it when a button is clicked.My problem is when the scroll postion is at the bottom of listview if I refresh the listview by clearing the adapter, again the scroll position will be at the bottom of the listview.I want the scroll postion to be focused at the top of the listview.

尝试使用:

myListView.setSelectionAfterHeaderView();

试试这个,位置为0/1。

yourListView.setSelection(position);

You can try this

list.smoothScrollToPosition(0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM