简体   繁体   中英

How to make two listviews scroll synchronously with one another in c#

I have listview1 and listview2, and want to make it so that when one is scrolled, the other also scrolls synchronously. How can I do this?

Try something like this in the OnScroll() method of OnScrollListener :

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

Another way, always implementing an AbsListView.OnScrollListener is that, when the ListView is scrolled, the OnScroll() method of OnScrollListener calls SmoothScrollToPosition() on the other ListView to synchronize to the same position.

This article and this article are implementing another approach, a little bit more complicated, that consists of creating a custom control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM