/** * 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中至关重要的一个类)