ListView getChildCount 以及getChildAt 坑 误区指南
今天调试的时候,才知道。
原来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 坑 误区指南的更多相关文章
- Android中ListView.getCount()与ListView.getChildCount()区别和OnScrollListener()各个参数的区别
istView.getCount()(实际上是 AdapterView.getCount()) 返回的是其 Adapter.getCount() 返回的值.也就是“所包含的 Item 总个数”. Li ...
- ListView.getChildCount() 详解
ListView.getCount() 返回的所包含的item总个数 ListView.getChildCount() (ViewGroup.getChildCount()) 返回的是现实层面上所包含 ...
- 【干货】基于镜像部署的Gitlab-CI/CD实践和坑位指南
引言 看过前文的博友可能注意到我是把 部署dll文件拷贝到生产机器,之后在生产机器上使用docker-compose即时创建镜像, 并没有完成CI/CD, 只是在原来传统部署方式下 将部署文件容器化. ...
- Android中GridView、ListView 的 getChildAt() 方法返回null 问题
开发的Android app用到了GridView或者ListView,通常使用getChildAt(int position)方法获取当前点击或者选中的View(即position对应的View). ...
- 两listview联动
package com.mttz; import java.util.ArrayList;import java.util.List; import com.mttz.adapter.CaiDanAD ...
- ListView只更新某个item
方案1:针对需要更新的item调用public View getView(int position, View convertView, ViewGroup parent)即可.如: public c ...
- Android使用ListView应该注意的地方
在ListView中设置Selector为null会报空指针? mListView.setSelector(null);//空指针 试试下面这种: mListView.setSelector(new ...
- ListView实现原理
转载:http://blog.csdn.net/guolin_blog/article/details/44996879 在Android所有常用的原生控件当中,用法最复杂的应该就是ListView了 ...
- Android ListView OnItemLongClick和OnItemClick事件内部细节分享以及几个比较特别的属性
本文转自 http://blog.sina.com.cn/s/blog_783ede030101bnm4.html 作者kiven 辞职3,4个月在家休息,本以为楼主要程序员逆袭,结果失败告终继续码农 ...
随机推荐
- WiFi调试手机
转自http://blog.csdn.net/Yejianyun1/article/details/55511726 使用场景: 1.多设备执行测试用例 2.数据线无法满足使用 电脑与手机的网络需要 ...
- lrzsz的使用
可以方便的在本地PC机和远程服务器之间传输文件. 1.下载 直接在centos上执行命令yum -y install lrzsz 2.上传文件 rz // 上传文件,执行命令rz,会跳出文件选择窗口, ...
- Redis 基础概念和命令
Redis 是什么 Redis是一种基于键值对(key-value)的NoSQL数据库. 为什么使用Redis 速度快 Redis的时间颗粒度一般是微秒,慢查询的默认值是10 000微秒,即10毫秒. ...
- Simotion应用案例,使用Simotion web server调试,使用Project Generator创建项目,Simosim模拟运行运行项目
Simotion web server simotion项目设计和调试过程中,web server功能越来越常用.例如Project generator生成的FBAxis, winder, print ...
- April 7 2017 Week 14 Friday
A good heart is better than all the brains in the world. 聪明绝顶,不如宅心仁厚. A good heart can be useful to ...
- BZOJ 4502: 串 AC自动机
4502: 串 Time Limit: 30 Sec Memory Limit: 512 MBSubmit: 195 Solved: 95[Submit][Status][Discuss] Des ...
- Selenium入门9 上传文件
上传文件步骤 1 找到文件上传的input标签 find_element_by_css_selector("input[type='file']") 2 用send_keys传入 ...
- python实现连续子数组的最大和
题目描述 HZ偶尔会拿些专业问题来忽悠那些非计算机专业的同学.今天测试组开完会后,他又发话了:在古老的一维模式识别中,常常需要计算连续子向量的最大和,当向量全为正数的时候,问题很好解决.但是,如果向量 ...
- java对象传递小解析
先上代码: import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder ...
- 前端HTML之表单
1.列表标签 1.1无序列表<ul>,当中每一层都是<li> <ul> <li>张三</li> <li>李四</li ...