0

I have two ListViews. Is there any way to synchronize the position of ListViews when I scroll both the Lists

Sundar_Mob
  • 155
  • 12
  • I have a working sollution please check this post http://stackoverflow.com/questions/11906263/how-to-syncronisize-two-listview-positions/16168749#16168749 – EvertvdBraak Apr 23 '13 at 11:58

2 Answers2

1

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);
Rajkiran
  • 15,845
  • 24
  • 74
  • 114
0

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

Tim
  • 6,692
  • 2
  • 25
  • 30