What is difference between getCount()
and getChildCount()
in ListView
?
Android: Difference between getCount() and getChildCount() in ListView
Asked Answered
getCount()
returns you a count of items in Adapter (total in list), getChildCount()
is a ViewGroup
method that returns you number of subviews. ListView
actively reuses views so if your list has 1000 items getCount()
will return 1000, getChildCount()
- around 10 or so...
getCount()
is the number of items in the adapter while getChildCount()
refers to the ViewGroup's method that returns the number of the views that this view contains.
In your adapter there is one Method getChildrenCount();
that decide how many child you want to create.
@Override
public int getChildrenCount(int groupPosition) {
return 1;
}
© 2022 - 2024 — McMap. All rights reserved.
listview.getChildAt(getCount() -1)
and get null pointer exception. – Ostensive