PreferenceViewHolder


public class PreferenceViewHolder extends RecyclerView.ViewHolder


A RecyclerView.ViewHolder class which caches views associated with the default Preference layouts. Cached views can be retrieved by calling findViewById.

Summary

Public methods

View

Returns a cached reference to a subview managed by this object.

boolean

Dividers are only drawn between items if both items allow it, or above the first and below the last item if that item allows it.

boolean

Dividers are only drawn between items if both items allow it, or above the first and below the last item if that item allows it.

void
setDividerAllowedAbove(boolean allowed)

Dividers are only drawn between items if both items allow it, or above the first and below the last item if that item allows it.

void
setDividerAllowedBelow(boolean allowed)

Dividers are only drawn between items if both items allow it, or above the first and below the last item if that item allows it.

Inherited methods

From androidx.recyclerview.widget.RecyclerView.ViewHolder
final int

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

final int

This method is deprecated.

This method is confusing when adapters nest other adapters.

final @Nullable RecyclerView.Adapter<RecyclerView.ViewHolder>

Returns the Adapter that last bound this ViewHolder.

final int

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

final long

Returns The itemId represented by this ViewHolder.

final int
final int

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

final int

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

final int

This method is deprecated.

This method is deprecated because its meaning is ambiguous due to the async handling of adapter updates.

final boolean
final void
setIsRecyclable(boolean recyclable)

Informs the recycler whether this item can be recycled.

String

Public methods

findViewById

Added in 1.0.0
public View findViewById(@IdRes int id)

Returns a cached reference to a subview managed by this object. If the view reference is not yet cached, it falls back to calling findViewById and caches the result.

Parameters
@IdRes int id

Resource ID of the view to find

Returns
View

The view, or null if no view with the requested ID is found

isDividerAllowedAbove

Added in 1.0.0
public boolean isDividerAllowedAbove()

Dividers are only drawn between items if both items allow it, or above the first and below the last item if that item allows it.

Returns
boolean

true if dividers are allowed above this item

isDividerAllowedBelow

Added in 1.0.0
public boolean isDividerAllowedBelow()

Dividers are only drawn between items if both items allow it, or above the first and below the last item if that item allows it.

Returns
boolean

true if dividers are allowed below this item

setDividerAllowedAbove

Added in 1.0.0
public void setDividerAllowedAbove(boolean allowed)

Dividers are only drawn between items if both items allow it, or above the first and below the last item if that item allows it. By default, onBindViewHolder will set this to the same value as returned by isSelectable, so that non-selectable items do not have a divider drawn above them.

Parameters
boolean allowed

False to prevent dividers being drawn above this item

setDividerAllowedBelow

Added in 1.0.0
public void setDividerAllowedBelow(boolean allowed)

Dividers are only drawn between items if both items allow it, or above the first and below the last item if that item allows it. By default, onBindViewHolder will set this to the same value as returned by isSelectable, so that non-selectable items do not have a divider drawn below them.

Parameters
boolean allowed

False to prevent dividers being drawn below this item