listview count vs adapter count in android

筅森魡賤 提交于 2019-12-04 12:24:58

ListView.getChildCount() returns the number of Views on the screen. Adapters getCount() returns the total number of objects in your list.

getChildCount()

getCount()

You might have 50 Strings in say an ArrayAdapter but only 10 are drawn on the screen at the current moment so your ListView count will be 10 but your Adapter count will be 50.

adapter.getCount() returns total objects count contained in it. listView.getChildCount() return number of views showed in this listview. Adapter uses caching mechanism, and a lot of views are reused, that's why it's number differs from that shown in adapter.getCount()

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