列表视图数与android的适配器数量 [英] listview count vs adapter count in android

查看:228
本文介绍了列表视图数与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. Adapters 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 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.

这篇关于列表视图数与android的适配器数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆