Tag Archives: Remember the location

Listview remembers location not itme location

In order to achieve better user experience in application development, listview needs to remember the last sliding position. Getscroll () always returns 0, because getscroll () is the view method.

Finally, I found this on Google:

// save index and top position  
int index = mList.getFirstVisiblePosition();  
View v = mList.getChildAt(0);  
int top = (v == null) ?0 : v.getTop();  

// ...  

// restore  
mList.setSelectionFromTop(index, top);