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个月在家休息,本以为楼主要程序员逆袭,结果失败告终继续码农 ...
随机推荐
- 只为更快、更省、更安全的 Azure CDN
来来来!小编今天要公布一件大事啦: 经过最近一次更新,Azure CDN 高级版服务 HTTPS SSL 证书的申请方式有所改进啦,除了现有的 Azure CDN 代为申请证书外,还支持用户自己申请的 ...
- check_mk手动安装
官方omd rpm包安装 yum -y install /tmp/check-mk-raw-1.2.6p2.demo-el6-34.x86_64.rpm omd create la omd confi ...
- Python3爬虫04(其他例子,如处理获取网页的内容)
#!/usr/bin/env python# -*- coding:utf-8 -*- import osimport reimport requestsfrom bs4 import Navigab ...
- C#中生成随机数的几种方法
Random 类 Random类默认的无参构造函数可以根据当前系统时钟为种子,进行一系列算法得出要求范围内的伪随机数 Random rd = new Random() rd.next(,)(生成1~1 ...
- Windows计算下载文件的SHA256 MD5 SHA1
引用自 http://blog.163.com/licanli2082@126/blog/static/35748686201284611330/ certutil -hashfile yourfil ...
- To my dear friends in SFAE
To my dear friends in SFAE, 这不是farewell,我还在西门子大家庭.2018年1月份我会转到SLC MCBU.在SFAE十年,一些敢想,唠叨唠叨~ 十年弹指一挥间.记得 ...
- 简单的NLog配置文件
NLog.config <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="h ...
- 365. Water and Jug Problem (GCD or BFS) TBC
https://leetcode.com/problems/water-and-jug-problem/description/ -- 365 There are two methods to sol ...
- hdu-1892 See you~---二维树状数组运用
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1892 题目大意: 题目大意:有很多方格,每个方格对应的坐标为(I,J),刚开始时每个格子里有1本书, ...
- 2017.11.1 微型计算机原理与接口技术-----第七章 中断系统与8237A DMA控制器
第七章 微型计算机原理与接口技术-----中断系统与8237A DMA控制器 (1)数据传送的两种方式:中断方式和直接存储器存取方式(DMA):中断是微处理器与外部设备交换信息的一种方式:DMA是存储 ...