Skip to content Skip to sidebar Skip to footer

Programmatically Set Position In Listview Without Scrolling

This is for a tablet running Android 4.4.2. I have a ListView with hundreds of items in it and about 20 are visible at a time. The user doesn't want the animation of smooth scrol

Solution 1:

There is a method in AbsListView, called smoothScrollToPositionFromTop() and it takes duration parameter. So if you set it to 0, you may do it without scrolling, animation.

smoothScrollToPositionFromTop.

Solution 2:

Solution is to getView of the row which is currently choosen to getTop.

Then to setSelectionFromTop from current position and getTop to highlight without scrolling:

lv.setSelectionFromTop(position,lv.getAdapter().getView(position,view,parent).getTop());

Post a Comment for "Programmatically Set Position In Listview Without Scrolling"