Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set scroll position to top of a listview

Tags:

android

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.

like image 275
nila Avatar asked Sep 15 '11 10:09

nila


1 Answers

check this

listview.setSelection(0);

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

like image 178
Pratik Avatar answered Sep 28 '22 02:09

Pratik