Android:RecyclerView的ChildHelper

本文介绍了Android中RecyclerView的ChildHelper类,用于管理RecyclerView的子视图。内容包括ChildHelper的创建、添加视图、移除视图和查找视图的源码实现。ChildHelper提供了忽略隐藏视图的常规方法和直接访问所有视图的未过滤方法。文章特别强调了添加视图时的位运算技巧和在布局过程中的作用。

RecyclerView作为我们常用的数据列表展示组件,它可以包含若干的子视图(child),那就会涉及到添加、删除、隐藏、查找等等操作,所以Android SDK提供了一个专门负责管理RecyclerView子视图的类,就是ChildHelper类。今天我们就来看看ChildHelper的源码实现。它的官方说明如下:

Helper class to manage children.
It wraps a RecyclerView and adds ability to hide some children. There are two sets of methods provided by this class. Regular methods are the ones that replicate ViewGroup methods like getChildAt, getChildCount etc. These methods ignore hidden children.
When RecyclerView needs direct access to the view group children, it can call unfiltered methods like get getUnfilteredChildCount or getUnfilteredChildAt.

 大概的意思就是说,ChildHelper是用来管理子视图的,它包含一对子视图的操作功能。它提供了两种方式,通常会使用ViewGroup的方法,比如getChildAt等,这些方法会忽略掉不可见的childview,如果RecyclerView想直接访问children

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bdmh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值