Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sync 2 ListViews by Scrolling [duplicate]

Possible Duplicate:
How to syncronisize two Listview positions
Sync 2 ListViews while Scrolling

I have two ListViews. Is there any way to synchronize the position of ListViews when I scroll any one of the Lists. I am implementing an AbsListView.OnScrollListener, registering to the ListView.

When the ListView is scrolled, the onScroll() method of OnScrollListener will be triggered, then i call smoothScrollToPosition(). But it don't work properly.

Can someone provide me any code example for this?...I Only want to Scroll One ListView and the other ListView moves synchronously. If you wan to know why i am using 2 ListView is because i am trying to make my own compound control that behaves as a DataGridView with a column fixed and headers

like image 281
arkmetal Avatar asked Nov 14 '22 00:11

arkmetal


1 Answers

Try something like

if( this.getScrollY() != otherList.getScrollY() )
    otherList.setScrollY( this.getScrollY() );

In the onScroll method of the onScrollListener. The above is pretty rough.

like image 57
Iain_b Avatar answered Jan 20 '23 05:01

Iain_b