ViewHolder
open class ViewHolder : RecyclerView.ViewHolder, FacetProvider
ViewHolder caches information about the action item layouts' subviews. Subclasses of may also wish to subclass this in order to add fields.
Summary
Public constructors |
Constructs an ViewHolder and caches the relevant subviews.
|
Constructs an ViewHolder for sub action and caches the relevant subviews.
|
Public methods |
open GuidedAction! |
|
open ImageView! |
Returns the checkmark view within this view holder's view.
|
open ImageView! |
Returns the chevron view within this view holder's view.
|
open View! |
Returns the content view within this view holder's view, where title and description are shown.
|
open TextView! |
Returns the description view within this view holder's view.
|
open EditText! |
Convenience method to return an editable version of the description, if possible, or null if the description view isn't an EditText.
|
open EditText! |
Convenience method to return an editable version of the title, if possible, or null if the title view isn't an EditText.
|
open View! |
|
open Any! |
|
open ImageView! |
Returns the icon view within this view holder's view.
|
open TextView! |
Returns the title view within this view holder's view.
|
open Boolean |
Returns true if in editing title, description, or activator View, false otherwise.
|
open Boolean |
Returns true if is in editing activator view with id guidedactions_activator_item, false otherwise.
|
open Boolean |
Returns true if the TextView is in editing description, false otherwise.
|
open Boolean |
Returns true if in editing title, description, so IME would be open.
|
open Boolean |
Returns true if the TextView is in editing title, false otherwise.
|
open Boolean |
|
Inherited functions |
From class ViewHolder
Int |
getAbsoluteAdapterPosition()
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 |
getAdapterPosition()
|
RecyclerView.Adapter<out RecyclerView.ViewHolder!>? |
getBindingAdapter()
Returns the Adapter that last bound this ViewHolder . Might return null if this ViewHolder is not bound to any adapter.
|
Int |
getBindingAdapterPosition()
Returns the Adapter position of the item represented by this ViewHolder with respect to the Adapter that bound it.
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 .
If the Adapter that bound this ViewHolder is inside another Adapter (e.g. ConcatAdapter ), this position might be different than getAbsoluteAdapterPosition() . If you would like to know the position that RecyclerView considers (e.g. for saved state), you should use getAbsoluteAdapterPosition() .
|
Long |
getItemId()
Returns The itemId represented by this ViewHolder.
|
Int |
getItemViewType()
|
Int |
getLayoutPosition()
Returns the position of the ViewHolder in terms of the latest layout pass.
This position is mostly used by RecyclerView components to be consistent while RecyclerView lazily processes adapter updates.
For performance and animation reasons, RecyclerView batches all adapter updates until the next layout pass. This may cause mismatches between the Adapter position of the item and the position it had in the latest layout calculations.
LayoutManagers should always call this method while doing calculations based on item positions. All methods in RecyclerView.LayoutManager , RecyclerView.State , RecyclerView.Recycler that receive a position expect it to be the layout position of the item.
If LayoutManager needs to call an external method that requires the adapter position of the item, it can use getAbsoluteAdapterPosition() or RecyclerView.Recycler#convertPreLayoutPositionToPostLayout(int) .
|
Int |
getOldPosition()
When LayoutManager supports animations, RecyclerView tracks 3 positions for ViewHolders to perform animations.
If a ViewHolder was laid out in the previous onLayout call, old position will keep its adapter index in the previous layout.
|
Int |
getPosition()
|
Boolean |
isRecyclable()
|
Unit |
setIsRecyclable(recyclable: Boolean)
Informs the recycler whether this item can be recycled. Views which are not recyclable will not be reused for other items until setIsRecyclable() is later set to true. Calls to setIsRecyclable() should always be paired (one call to setIsRecyclabe(false) should always be matched with a later call to setIsRecyclable(true)). Pairs of calls may be nested, as the state is internally reference-counted.
|
String |
toString()
|
|
Public constructors
<init>
ViewHolder(v: View!)
Constructs an ViewHolder and caches the relevant subviews.
<init>
ViewHolder(
v: View!,
isSubAction: Boolean)
Constructs an ViewHolder for sub action and caches the relevant subviews.
Public methods
getCheckmarkView
open fun getCheckmarkView(): ImageView!
Returns the checkmark view within this view holder's view.
getChevronView
open fun getChevronView(): ImageView!
Returns the chevron view within this view holder's view.
getContentView
open fun getContentView(): View!
Returns the content view within this view holder's view, where title and description are shown.
getDescriptionView
open fun getDescriptionView(): TextView!
Returns the description view within this view holder's view.
getEditableDescriptionView
open fun getEditableDescriptionView(): EditText!
Convenience method to return an editable version of the description, if possible, or null if the description view isn't an EditText.
getEditableTitleView
open fun getEditableTitleView(): EditText!
Convenience method to return an editable version of the title, if possible, or null if the title view isn't an EditText.
getEditingView
open fun getEditingView(): View!
Return |
View! |
Current editing title view or description view or activator view or null if not in editing. |
getFacet
open fun getFacet(facetClass: Class<*>!): Any!
getIconView
open fun getIconView(): ImageView!
Returns the icon view within this view holder's view.
getTitleView
open fun getTitleView(): TextView!
Returns the title view within this view holder's view.