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个月在家休息,本以为楼主要程序员逆袭,结果失败告终继续码农 ...
随机推荐
- 【QT】Qaction和触发函数建立连接的方法
说明:我是在ui里面编辑好控件以及位置,然后在程序里面将控件和触发函数进行绑定,实现的触发操作. 代码如下: MainWindow::MainWindow(QWidget *parent) : QMa ...
- C4C Product Price List的模型中和有效期相关的两个字段
SAP C4C的price list实例可以在工作中心Products,视图Price Lists里看到. 我们点开第二个名为TEST的实例: 我写这篇文章的日期是2018年10月27日, 我现在把这 ...
- 1929. Teddybears are not for Everyone (Timus) (combination+reading questions)
http://acm.timus.ru/problem.aspx?space=1&num=1929 combination problems. 排列组合问题. According to the ...
- 获取url中的某个字段的值
function getUrl(name, url) { url = url || window.location.search; var reg = new RegExp("(^|& ...
- Java访问重定向接口
背景:开发做了一个免登陆的接口,方便我后续给管理后台做一些小工具,问题来了,给的免登陆接口是个302如图的test_login,在重定向一个200的接口(eload_admin), 原本开始这样做:0 ...
- python同时遍历数组的索引和元素
1.一般要同时遍历数组的索引和元素需要先确定数组的长度length(元素个数),然后使用range函数来生成数组的索引,最后使用该索引来访问数组的元素. 具体做法如下: l = [2,7,11,15] ...
- this指向问题(2)
4.显示绑定 指的是apply.bind.call (1).apply 和 call 相同点: <1> 这两个方法的用途是在特定的作用域中调用函数,实际上等于设置函数体内 this 对象的 ...
- List<T>转换为二维数组
public <T> Object[][] toArrays(List<T> data){ Object[][] o=new Object[data.size()][20]; ...
- Linux 性能检查常用命令
####消耗CPU最多的进程 [root@Yong ~]# ;|head ##拼接进程号 [root@Yong ~]# |awk '{print $1}' |awk BEGIN{RS=EOF}'{gs ...
- Python 创建项目、应用
1.创建项目 django-admin startproject TestPython 2.创建应用 python3 manage.py startapp books 3.目录讲解 ├── TestP ...