列表视图数与android的适配器数量 [英] listview count vs adapter count in android
问题描述
为什么 listview.getChildCount()
和 adapter.getCount()
返回不同的值?我有一个onScroll方法,并从内部看,如果我致电上述方法,每个方法返回不同的值。有谁知道为什么吗?
Why do listview.getChildCount()
and adapter.getCount()
return different values? I have an onScroll method and from within it, if I call the methods above, each return different values. Does anyone know why?
推荐答案
ListView.getChildCount()
返回意见的数量
在屏幕上。 适配器
取值 getCount将()
返回列表中的对象的总数。
ListView.getChildCount()
returns the number of Views
on the screen. Adapter
s getCount()
returns the total number of objects in your list.
<一个href=\"http://developer.android.com/reference/android/view/ViewGroup.html#getChildCount%28%29\">getChildCount()
<一个href=\"http://developer.android.com/reference/android/widget/Adapter.html#getCount%28%29\">getCount()
您可能有50 字符串
S IN说,一个 ArrayAdapter
,但只有10个在当前绘制在屏幕上瞬间让你的的ListView
计数将是10,但你的适配器
数将在50。
You might have 50 String
s 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.
这篇关于列表视图数与android的适配器数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!