Is there a way to find out how many items in the list view are displayed?

I want to take a specific action on list items that the user can see without scrolling. In any case, to get the number of items shown or is there any other way to get closer to this?

+4
source share
3 answers

I don’t know what exactly is your requirement, but in order to know the list items that are currently visible

ListView.getFirstVisiblePosition(); ListView.getLastVisiblePosition(); 
+15
source

You can find the number of listview items below:

 int count = listview.getChildCount(); 
+3
source

Your ListView can implement onScrollListener , where you can override its onScroll method. The method receives the following arguments:

  public void onScroll (AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {}

Perhaps you can start with this.

+2
source

All Articles