Last active
August 29, 2015 14:19
-
-
Save Kisty/e2c3cd956a01a19661e8 to your computer and use it in GitHub Desktop.
Programatically scroll to a position in a ListView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void scrollToPosition(ListView lv, int position, boolean clipToPadding) { | |
scrollToPositionFromTop(lv, position, 0, clipToPadding); | |
} | |
public void scrollToPositionFromTop(ListView lv, int item, int y, boolean clipToPadding) { | |
//Had to apply this offset if clipToPadding="false" | |
if (!clipToPadding) { | |
item -= lv.getPaddingTop(); | |
} | |
this.setSelectionFromTop(position, y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment