开发者

How to set scroll position to top of a listview

开发者 https://www.devze.com 2023-04-05 14:15 出处:网络
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 p

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开发者_Python百科 want the scroll postion to be focused at the top of the listview.


check this

listview.setSelection(0);

http://developer.android.com/reference/android/widget/ListView.html#setSelection%28int%29


Try using:

myListView.setSelectionAfterHeaderView();


Try this, with position to 0/1.

yourListView.setSelection(position);


You can try this

list.smoothScrollToPosition(0);
0

精彩评论

暂无评论...
验证码 换一张
取 消