RecycledViewPool
open class RecycledViewPool
kotlin.Any | |
↳ | androidx.recyclerview.widget.RecyclerView.RecycledViewPool |
RecycledViewPool lets you share Views between multiple RecyclerViews.
If you want to recycle views across RecyclerViews, create an instance of RecycledViewPool and use RecyclerView#setRecycledViewPool(RecycledViewPool)
.
RecyclerView automatically creates a pool for itself if you don't provide one.
Summary
Public constructors | |
---|---|
<init>() RecycledViewPool lets you share Views between multiple RecyclerViews. |
Public methods | |
---|---|
open Unit |
clear() Discard all ViewHolders. |
open RecyclerView.ViewHolder? |
getRecycledView(viewType: Int) Acquire a ViewHolder of the specified type from the pool, or |
open Int |
getRecycledViewCount(viewType: Int) Returns the current number of Views held by the RecycledViewPool of the given view type. |
open Unit |
putRecycledView(scrap: RecyclerView.ViewHolder!) Add a scrap ViewHolder to the pool. |
open Unit |
setMaxRecycledViews(viewType: Int, max: Int) Sets the maximum number of ViewHolders to hold in the pool before discarding. |
Public constructors
<init>
RecycledViewPool()
RecycledViewPool lets you share Views between multiple RecyclerViews.
If you want to recycle views across RecyclerViews, create an instance of RecycledViewPool and use RecyclerView#setRecycledViewPool(RecycledViewPool)
.
RecyclerView automatically creates a pool for itself if you don't provide one.
Public methods
getRecycledView
@Nullable open fun getRecycledView(viewType: Int): RecyclerView.ViewHolder?
Acquire a ViewHolder of the specified type from the pool, or null
if none are present.
Parameters | |
---|---|
viewType |
Int: ViewHolder type. |
Return | |
---|---|
RecyclerView.ViewHolder? |
ViewHolder of the specified type acquired from the pool, or null if none are present. |
getRecycledViewCount
open fun getRecycledViewCount(viewType: Int): Int
Returns the current number of Views held by the RecycledViewPool of the given view type.
putRecycledView
open fun putRecycledView(scrap: RecyclerView.ViewHolder!): Unit
Add a scrap ViewHolder to the pool.
If the pool is already full for that ViewHolder's type, it will be immediately discarded.
Parameters | |
---|---|
scrap |
RecyclerView.ViewHolder!: ViewHolder to be added to the pool. |