2

I am having two listviews in parallel on single screen. Both are having their own scroll listener.

What I want to do is scroll the first listview, then the second listview should also scroll and vice versa.

Is this possible ?

gotqn
  • 42,737
  • 46
  • 157
  • 243
Bunny
  • 576
  • 4
  • 19
  • may be you can find out your answer from this http://stackoverflow.com/questions/12342419/android-scrolling-2-listviews-together – Lalit Jadav Oct 20 '16 at 04:21

1 Answers1

0

Suppose your ListViews are mListView1 and mListView2, then do something like this -

  mListView1.setOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {}                   

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem,
                int visibleItemCount, int totalItemCount) {

            // Smooth scroll mListView2 according to mListView1.
            mListView2.smoothScrollToPosition(firstVisibleItem);
        }

        @Override
        private void isScrollCompleted() {}
    });
mihirjoshi
  • 12,161
  • 7
  • 47
  • 78
  • But my both listviews having header. So in case when header is half visible for first listview, how to scroll another listview exactly at same place. – Bunny Aug 01 '15 at 09:01
  • And if i use your without having header on listview, what if i scroll the first listview such that only half of any child is visible on top ? – Bunny Aug 01 '15 at 09:13