Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.


abstract class ViewHolder
   ↳ androidx.recyclerview.widget.RecyclerView.ViewHolder

A ViewHolder describes an item view and metadata about its place within the RecyclerView.

Adapter implementations should subclass ViewHolder and add fields for caching potentially expensive View#findViewById(int) results.

While LayoutParams belong to the LayoutManager, ViewHolders belong to the adapter. Adapters should feel free to use their own custom ViewHolder implementations to store data that makes binding view contents easier. Implementations should assume that individual item views will hold strong references to ViewHolder objects and that RecyclerView instances may hold strong references to extra off-screen item views for caching purposes


Public constructors
<init>(@NonNull itemView: View)

Public methods

Returns the Adapter position of the item represented by this ViewHolder with respect to the RecyclerView's Adapter.


RecyclerView.Adapter<out RecyclerView.ViewHolder!>?

Returns the Adapter that last bound this ViewHolder.


Returns the Adapter position of the item represented by this ViewHolder with respect to the Adapter that bound it.


Returns The itemId represented by this ViewHolder.



Returns the position of the ViewHolder in terms of the latest layout pass.


When LayoutManager supports animations, RecyclerView tracks 3 positions for ViewHolders to perform animations.



setIsRecyclable(recyclable: Boolean)

Informs the recycler whether this item can be recycled.

open String


Public constructors


ViewHolder(@NonNull itemView: View)

Public methods


fun getAbsoluteAdapterPosition(): Int

Returns the Adapter position of the item represented by this ViewHolder with respect to the RecyclerView's Adapter. If the Adapter that bound this ViewHolder is inside another adapter (e.g. ConcatAdapter), this position might be different and will include the offsets caused by other adapters in the ConcatAdapter.

Note that this might be different than the getLayoutPosition() if there are pending adapter updates but a new layout pass has not happened yet.

RecyclerView does not handle any adapter updates until the next layout traversal. This may create temporary inconsistencies between what user sees on the screen and what adapter contents have. This inconsistency is not important since it will be less than 16ms but it might be a problem if you want to use ViewHolder position to access the adapter. Sometimes, you may need to get the exact adapter position to do some actions in response to user events. In that case, you should use this method which will calculate the Adapter position of the ViewHolder.

Note that if you've called RecyclerView.Adapter#notifyDataSetChanged(), until the next layout pass, the return value of this method will be NO_POSITION.

Note that if you are querying the position as RecyclerView sees, you should use getAbsoluteAdapterPosition() (e.g. you want to use it to save scroll state). If you are querying the position to access the Adapter contents, you should use getBindingAdapterPosition().

Int The adapter position of the item from RecyclerView's perspective if it still exists in the adapter and bound to a valid item. RecyclerView#NO_POSITION if item has been removed from the adapter, RecyclerView.Adapter#notifyDataSetChanged() has been called after the last layout pass or the ViewHolder has already been recycled.


fun getAdapterPosition(): Int

Deprecated: This method is confusing when adapters nest other adapters. If you are calling this in the context of an Adapter, you probably want to call getBindingAdapterPosition() or if you want the position as RecyclerView sees it, you should call getAbsoluteAdapterPosition().