0

I used Synchronise ScrollView scroll positions - android to synchronize 2 scroll views . I this we implement an interface an

protected void onScrollChanged(int x, int y, int oldx, int oldy); .

now can anybody tell me how to use this inteface or any other method for synchronizing four views simultaneously because onScrollChanged() in in-build method and use coordinate of only 2 scroll views. but I have to scroll 4 views. If there is any method please tell me. Thanks in advance.

Community
  • 1
  • 1

1 Answers1

0

I guess you can do something like

    if(scrollView == scrollView1) {
        scrollView2.scrollTo(x, y);
        scrollView3.scrollTo(x, y);
        scrollView4.scrollTo(x, y);
    } else if(scrollView == scrollView2) {
        scrollView1.scrollTo(x, y);
        scrollView3.scrollTo(x, y);
        scrollView4.scrollTo(x, y);
    } else if(scrollView == scrollView3) {
        scrollView1.scrollTo(x, y);
        scrollView2.scrollTo(x, y);
        scrollView4.scrollTo(x, y);
    } else if(scrollView == scrollView4) {
        scrollView1.scrollTo(x, y);
        scrollView2.scrollTo(x, y);
        scrollView3.scrollTo(x, y);
    }
Marc Van Daele
  • 2,856
  • 1
  • 26
  • 52
  • Thanks for reply. I tried This But It gives nullpointer exception on scrollview3. are there some modification done on Onscrollchanged Interface .Because that is responsible for scrolling. –  Feb 09 '12 at 16:05
  • and is scollView3 != null in onCreate? Maybe you can first call the findViewById 4 times and next set the setScrollViewListener: this avoids that onScrollChanged is already called before scollView3/4 are created/initialized. – Marc Van Daele Feb 09 '12 at 16:10
  • Thank You very much . that work fine. and make me to move forward –  Feb 09 '12 at 16:19