Reputation: 155
I have two ListViews. Is there any way to synchronize the position of ListViews when I scroll both the Lists
Upvotes: 0
Views: 2333
Reputation: 6712
You could use this in your second list view: smoothScrollToPosition(position)
And in your first ListView you could use a OnScrollListener and check the first visible item with getFirstVisiblePosition.
Best wishes, Tim
Upvotes: 0
Reputation: 16193
Use the following method to get the scroll position of your first listView-
private void saveListScrollPosition()
{
// save index and top position
index = _listview1.getFirstVisiblePosition();
View view = _listview1.getChildAt(0);
top = (view == null) ? 0 : view.getTop();
}
And scroll the second listView to that position with-
// restore
_listview2.setSelectionFromTop(index, top);
Upvotes: 1