Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

What is difference between getCount() and getChildCount() in ListView?

like image 888
Paulius Vindzigelskis Avatar asked Apr 20 '12 08:04

Paulius Vindzigelskis


2 Answers

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...

like image 97
EvilDuck Avatar answered Nov 14 '22 18:11

EvilDuck


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.

like image 45
Renard Avatar answered Nov 14 '22 18:11

Renard