今天调试的时候,才知道。

原来listview 的 getChildCount 取得是当前可先的list item 的个数,而不是整个listview 的count.

整个listview 的数量应该是 getCount

/**
* @return The number of items owned by the Adapter associated with this
* AdapterView. (This is the number of data items, which may be
* larger than the number of visible views.)
*/
@ViewDebug.CapturedViewProperty
public int getCount() {
return mItemCount;
}

getChildCount

/**
* Returns the number of children in the group.
*
* @return a positive integer representing the number of children in
* the group
*/
public int getChildCount() {
return mChildrenCount;
} /**
* Returns the view at the specified position in the group.
*
* @param index the position at which to get the view from
* @return the view at the specified position or null if the position
* does not exist within the group
*/
public View getChildAt(int index) {
if (index < 0 || index >= mChildrenCount) {
return null;
}
return mChildren[index];
}

总结:

getChildCount 和 getChildAt 都是取得listView当前可见的item.

ListView getChildCount 以及getChildAt 坑 误区指南的更多相关文章

  1. Android中ListView.getCount()与ListView.getChildCount()区别和OnScrollListener()各个参数的区别

    istView.getCount()(实际上是 AdapterView.getCount()) 返回的是其 Adapter.getCount() 返回的值.也就是“所包含的 Item 总个数”. Li ...

  2. ListView.getChildCount() 详解

    ListView.getCount() 返回的所包含的item总个数 ListView.getChildCount() (ViewGroup.getChildCount()) 返回的是现实层面上所包含 ...

  3. 【干货】基于镜像部署的Gitlab-CI/CD实践和坑位指南

    引言 看过前文的博友可能注意到我是把 部署dll文件拷贝到生产机器,之后在生产机器上使用docker-compose即时创建镜像, 并没有完成CI/CD, 只是在原来传统部署方式下 将部署文件容器化. ...

  4. Android中GridView、ListView 的 getChildAt() 方法返回null 问题

    开发的Android app用到了GridView或者ListView,通常使用getChildAt(int position)方法获取当前点击或者选中的View(即position对应的View). ...

  5. 两listview联动

    package com.mttz; import java.util.ArrayList;import java.util.List; import com.mttz.adapter.CaiDanAD ...

  6. ListView只更新某个item

    方案1:针对需要更新的item调用public View getView(int position, View convertView, ViewGroup parent)即可.如: public c ...

  7. Android使用ListView应该注意的地方

    在ListView中设置Selector为null会报空指针? mListView.setSelector(null);//空指针 试试下面这种: mListView.setSelector(new ...

  8. ListView实现原理

    转载:http://blog.csdn.net/guolin_blog/article/details/44996879 在Android所有常用的原生控件当中,用法最复杂的应该就是ListView了 ...

  9. Android ListView OnItemLongClick和OnItemClick事件内部细节分享以及几个比较特别的属性

    本文转自 http://blog.sina.com.cn/s/blog_783ede030101bnm4.html 作者kiven 辞职3,4个月在家休息,本以为楼主要程序员逆袭,结果失败告终继续码农 ...

随机推荐

  1. staticmethod classmethod property方法

    @staticmethod 静态方法 函数修饰符,用来修饰一个函数,类似于装饰器 class Dog(object): def __init__(self,name): self.name = nam ...

  2. selenium 移动端测试

    selenium 可以进行移动测试的.Anroid ,IOS .进行移动端测试,需要相应的SDK ,apk.其中anriod 是selenium 支持有2中选择,remote server 和 tes ...

  3. 一次ddos攻击

    公司lvs的vip受到攻击,表现现象为: 1)vip所有服务器没有什么连接,大量的无效connection 2)网卡流量很大 停用vip,流量下降,临时解决攻击问题.但是这只是治标不治本,如果攻击方变 ...

  4. Linux命令之创建文件夹3

    1)mkdir  fyr即可在当前目录下创建一个文件夹 2)在fyr文件夹下创建一个子目录 mkdir fyr/fyr1 注意:如果不存在父层目录直接创建对应父层目录下的子目录mkdir  FYR/f ...

  5. IOS中 copy ,strong ,weak ,assign使用区别

      .@property属性的用法 * weak(assign) :  代理\UI控件 * strong(retain) : 数组.模型)其他对象(除代理\UI控件\字符串以外的对象) * copy ...

  6. 使用loadrunner 12 手动关联

    关联的含义: 如浏览器打发送一个网页A请求,服务器返回这个请求,并且在返回的内容中携带一个session id=key,当浏览器再送出网页B的请求时,这时就要用ID=key的数据,服务器才会认为这是合 ...

  7. 20145238-荆玉茗 《Java程序设计》第6周学习总结

    20145238 <Java程序设计>第6周学习总结 教材学习内容总结 第十章输入和输出 10.1.1 ·如果要将数据从来源中取出,可以使用输入串流,若将数据写入目的地,可以使用输出串流. ...

  8. 你视为意见领袖的大 V,可能只是个僵尸号

    今日导读 “高手在民间”这句话诚不欺我.互联网普及之后,民间大神在各大论坛如雨后春笋般涌现,忽而指点江山,笑谈国际风云,忽而算无遗策,狙击股市庄家,亦或退而求其次,美妆美食美颜,誓要带领少男少女冲在时 ...

  9. Fluent经典问题答疑

    原文链接1 原文链接28 什么叫边界条件?有何物理意义?它与初始条件有什么关系? 边界条件与初始条件是控制方程有确定解的前提. 边界条件是在求解区域的边界上所求解的变量或其导数随时间和地点的变化规律. ...

  10. Maven tomcat插件 远程发布【Learn】

    Tomcat配置修改: ①.conf/tomcat-users.xml <role rolename="manager-gui"/> <role rolename ...