Search code examples
androidandroid-listfragment

Android - How to get size of / length / number of items in a ListFragment?


For example, something like...

int numItemsInMyListFragment = myListFragment.size();

...that is obviously valid??

Update: I've just discovered the answer by doing a similar search for ListActivity, so I'll post the answer below...


Solution

  • int numItemsInMyListFragment = myListFragment.getListView().getCount();