Adapter
abstract class Adapter<VH : RecyclerView.ViewHolder!>
kotlin.Any | |
↳ | androidx.recyclerview.widget.RecyclerView.Adapter |
Base class for an Adapter
Adapters provide a binding from an app-specific data set to views that are displayed within a RecyclerView
.
Summary
Nested classes | |
---|---|
Defines how this Adapter wants to restore its state after a view reconstruction (e.g. configuration change). |
Public constructors | |
---|---|
<init>() Base class for an Adapter |
Public methods | |
---|---|
Unit |
bindViewHolder(@NonNull holder: VH, position: Int) This method internally calls |
VH |
createViewHolder(@NonNull parent: ViewGroup, viewType: Int) This method calls |
open Int |
findRelativeAdapterPositionIn(@NonNull adapter: RecyclerView.Adapter<out RecyclerView.ViewHolder!>, @NonNull viewHolder: RecyclerView.ViewHolder, localPosition: Int) Returns the position of the given |
abstract Int |
Returns the total number of items in the data set held by the adapter. |
open Long |
Return the stable ID for the item at |
open Int |
getItemViewType(position: Int) Return the view type of the item at |
RecyclerView.Adapter.StateRestorationPolicy |
Returns when this Adapter wants to restore the state. |
Boolean |
Returns true if one or more observers are attached to this adapter. |
Boolean |
Returns true if this adapter publishes a unique |
Unit |
Notify any registered observers that the data set has changed. |
Unit |
notifyItemChanged(position: Int) Notify any registered observers that the item at |
Unit |
notifyItemChanged(position: Int, @Nullable payload: Any?) Notify any registered observers that the item at |
Unit |
notifyItemInserted(position: Int) Notify any registered observers that the item reflected at |
Unit |
notifyItemMoved(fromPosition: Int, toPosition: Int) Notify any registered observers that the item reflected at |
Unit |
notifyItemRangeChanged(positionStart: Int, itemCount: Int) Notify any registered observers that the |
Unit |
notifyItemRangeChanged(positionStart: Int, itemCount: Int, @Nullable payload: Any?) Notify any registered observers that the |
Unit |
notifyItemRangeInserted(positionStart: Int, itemCount: Int) Notify any registered observers that the currently reflected |
Unit |
notifyItemRangeRemoved(positionStart: Int, itemCount: Int) Notify any registered observers that the |
Unit |
notifyItemRemoved(position: Int) Notify any registered observers that the item previously located at |
open Unit |
onAttachedToRecyclerView(@NonNull recyclerView: RecyclerView) Called by RecyclerView when it starts observing this Adapter. |
abstract Unit |
onBindViewHolder(@NonNull holder: VH, position: Int) Called by RecyclerView to display the data at the specified position. |
open Unit |
onBindViewHolder(@NonNull holder: VH, position: Int, @NonNull payloads: MutableList<Any!>) Called by RecyclerView to display the data at the specified position. |
abstract VH |
onCreateViewHolder(@NonNull parent: ViewGroup, viewType: Int) Called when RecyclerView needs a new |
open Unit |
onDetachedFromRecyclerView(@NonNull recyclerView: RecyclerView) Called by RecyclerView when it stops observing this Adapter. |
open Boolean |
onFailedToRecycleView(@NonNull holder: VH) Called by the RecyclerView if a ViewHolder created by this Adapter cannot be recycled due to its transient state. |
open Unit |
onViewAttachedToWindow(@NonNull holder: VH) Called when a view created by this adapter has been attached to a window. |
open Unit |
onViewDetachedFromWindow(@NonNull holder: VH) Called when a view created by this adapter has been detached from its window. |
open Unit |
onViewRecycled(@NonNull holder: VH) Called when a view created by this adapter has been recycled. |
open Unit |
registerAdapterDataObserver(@NonNull observer: RecyclerView.AdapterDataObserver) Register a new observer to listen for data changes. |
open Unit |
setHasStableIds(hasStableIds: Boolean) Indicates whether each item in the data set can be represented with a unique identifier of type |
open Unit |
setStateRestorationPolicy(@NonNull strategy: RecyclerView.Adapter.StateRestorationPolicy) Sets the state restoration strategy for the Adapter. |
open Unit |
unregisterAdapterDataObserver(@NonNull observer: RecyclerView.AdapterDataObserver) Unregister an observer currently listening for data changes. |
Public constructors
<init>
Adapter()
Base class for an Adapter
Adapters provide a binding from an app-specific data set to views that are displayed within a RecyclerView
.
Public methods
bindViewHolder
fun bindViewHolder(
@NonNull