Android——RecyclerView——Recycler类——源码注释翻译:Recycler类的官方解释

/**
 * A Recycler is responsible for managing scrapped or detached item views for reuse.
 *
 * <p>A "scrapped" view is a view that is still attached to its parent RecyclerView but
 * that has been marked for removal or reuse.</p>
 *
 * <p>Typical use of a Recycler by a {@link LayoutManager} will be to obtain views for
 * an adapter's data set representing the data at a given position or item ID.
 * If the view to be reused is considered "dirty" the adapter will be asked to rebind it.
 * If not, the view can be quickly reused by the LayoutManager with no further work.
 * Clean views that have not {@link android.view.View#isLayoutRequested() requested layout}
 * may be repositioned by a LayoutManager without remeasurement.</p>
 */

一个Recycler类是用来管理报废的或者被分离的item用于重新使用。


报废视图指的是一个view仍然与他的父recyclerView有联系的但是已经被标记为删除或者重用。


典型的使用Recycler的方法是通过一个将会获取views为了一个适配器的被给予位置或者itemid的数据集的LayoutManager。


如果这个视图将被重用会被认为是污染了Adapter将会被命令去重新绑定他。


如果没有,视图将会被LayoutManager快速地重用而不需要进行进一步的工作。


清理那些没有用isLayoutRequested() requested layout方法来请求布局的视图可以由LayoutManager重新定位而不需要重新测量。



总结:Recycler类是用来管理报废或者被分离的ViewHolder用于重新使用。(相当于回收站,是RecyclerView中至关重要的一个类)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值