问题
What is difference between getCount() and getChildCount() in ListView?
回答1:
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...
回答2:
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.
回答3:
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;
}
来源:https://stackoverflow.com/questions/10242800/android-difference-between-getcount-and-getchildcount-in-listview