Skip to content Skip to sidebar Skip to footer

Scroll A Particular Listview Item Into View

In my application, I have a ListView. The data for each item in the list is an instance of the SomeItem class. The list has a custom ArrayAdapter which has a custom view to display

Solution 1:

You can try the following:

  1. Calculate the position of the SomeItem item you want to make visible. You can do this by iterating over the list of SomeItems that you pass to the adapter.

  2. Use listView.getFirstVisiblePosition(), listView.getLastVisiblePosition() and the calculated position to check if the item is visible on the list.

  3. If the item is not visible, make listView scroll to it by calling listView.smoothScrollToPosition(calculatedPosition).

Post a Comment for "Scroll A Particular Listview Item Into View"