RecyclerView.RecycledViewPool


class 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 setRecycledViewPool.

RecyclerView automatically creates a pool for itself if you don't provide one.

Summary

Public constructors

Public functions

Unit

Discard all ViewHolders.

RecyclerView.ViewHolder?
getRecycledView(viewType: Int)

Acquire a ViewHolder of the specified type from the pool, or null if none are present.

Int

Returns the current number of Views held by the RecycledViewPool of the given view type.

Unit

Add a scrap ViewHolder to the pool.

Unit
setMaxRecycledViews(viewType: Int, max: Int)

Sets the maximum number of ViewHolders to hold in the pool before discarding.

Public constructors

RecycledViewPool

Added in 1.0.0
RecycledViewPool()

Public functions

clear

Added in 1.0.0
fun clear(): Unit

Discard all ViewHolders.

getRecycledView

Added in 1.0.0
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.

Returns
RecyclerView.ViewHolder?

ViewHolder of the specified type acquired from the pool, or null if none are present.

getRecycledViewCount

Added in 1.0.0
fun getRecycledViewCount(viewType: Int): Int

Returns the current number of Views held by the RecycledViewPool of the given view type.

putRecycledView

Added in 1.0.0
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.

setMaxRecycledViews

Added in 1.0.0
fun setMaxRecycledViews(viewType: Int, max: Int): Unit

Sets the maximum number of ViewHolders to hold in the pool before discarding.

Parameters
viewType: Int

ViewHolder Type

max: Int

Maximum number