RecyclerView.RecycledViewPool
public 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 methods |
|
|---|---|
void |
clear()Discard all ViewHolders. |
@Nullable RecyclerView.ViewHolder |
getRecycledView(int viewType)Acquire a ViewHolder of the specified type from the pool, or |
int |
getRecycledViewCount(int viewType)Returns the current number of Views held by the RecycledViewPool of the given view type. |
void |
Add a scrap ViewHolder to the pool. |
void |
setMaxRecycledViews(int viewType, int max)Sets the maximum number of ViewHolders to hold in the pool before discarding. |
Public constructors
Public methods
getRecycledView
public @Nullable RecyclerView.ViewHolder getRecycledView(int viewType)
Acquire a ViewHolder of the specified type from the pool, or null if none are present.
| Parameters | |
|---|---|
int viewType |
ViewHolder type. |
| Returns | |
|---|---|
@Nullable RecyclerView.ViewHolder |
ViewHolder of the specified type acquired from the pool, or |
getRecycledViewCount
public int getRecycledViewCount(int viewType)
Returns the current number of Views held by the RecycledViewPool of the given view type.
putRecycledView
public void putRecycledView(RecyclerView.ViewHolder scrap)
Add a scrap ViewHolder to the pool.
If the pool is already full for that ViewHolder's type, it will be immediately discarded.
| Parameters | |
|---|---|
RecyclerView.ViewHolder scrap |
ViewHolder to be added to the pool. |
setMaxRecycledViews
public void setMaxRecycledViews(int viewType, int max)
Sets the maximum number of ViewHolders to hold in the pool before discarding.
| Parameters | |
|---|---|
int viewType |
ViewHolder Type |
int max |
Maximum number |