6

I'm using a MergeAdapter (from Mark Murphy's excellent series of projects). You use it with a ListView. I'm trying to rebuild the contents of the adapter on a refresh (instead of refreshing "in place" and calling notifyDataSetChange()).

I'd like to get the y-scroll value of the listview so I can reset to that after I rebuild my list. This doesn't seem to be possible?

Thanks

user291701
  • 34,331
  • 68
  • 176
  • 277

1 Answers1

1

Implement OnScrollListener for your listview.

@Override
public void onScroll(AbsListView absListView, int firstVisible, int visibleCount, int totalCount) { 
//firstvisible is your first visible item in the list
}
Tarun
  • 13,357
  • 8
  • 39
  • 57
  • 6
    Right but that doesn't tell us the exact scroll position in pixels, right? I want to call ListView.scrollTo(x, y) after I refresh my list. But the OnScrollListener just tells you the visible items, not their position or anything. – user291701 Jun 02 '12 at 20:47
  • 2
    Check out http://stackoverflow.com/questions/3014089/scroll-to-a-position-in-a-listview – Tarun Jun 03 '12 at 05:32
  • Does not work : onScroll only work for views like ScrollView. – Teovald Dec 20 '13 at 16:53
  • The correct [solution](http://stackoverflow.com/questions/12727594/android-listview-current-scroll-location-y-pixels/35594825#35594825) – Sarasranglt Feb 24 '16 at 06:33