Android: Difference between getCount() and getChildCount() in ListView

十年热恋 提交于 2019-12-17 16:18:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!