Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

ViewHolder

open class ViewHolder : Presenter.ViewHolder
kotlin.Any
   ↳ androidx.leanback.widget.Presenter.ViewHolder
   ↳ androidx.leanback.widget.RowPresenter.ViewHolder

A ViewHolder for a Row.

Summary

Public constructors

<init>(view: View!)

Constructor for ViewHolder.

Public methods

RowHeaderPresenter.ViewHolder!

Returns the view holder for the Row header for this Row.

BaseOnItemViewClickedListener<Any!>!

Returns the listener for item click event.

BaseOnItemViewSelectedListener<Any!>!

Returns the listener for item or row selection.

open OnKeyListener!

Returns the key listener.

Row!

Returns the row bound to this ViewHolder.

Any!

Returns the Row object bound to this ViewHolder.

Float

Returns the current selection level of the Row.

open Any!

Return currently selected item inside a row ViewHolder.

open Presenter.ViewHolder!

Return ViewHolder of currently selected item inside a row ViewHolder.

Boolean

Returns whether the Row is in its expanded state.

Boolean

Returns whether the Row is selected.

Unit
setActivated(activated: Boolean)

Sets the row view's activated status.

Unit

Sets the listener for item click event.

Unit

Sets the listener for item or row selection.

open Unit

Sets a key listener.

Unit

Synchronizes the activated status of view to the last value passed through RowPresenter.ViewHolder#setActivated(boolean).

Inherited functions

Properties

ColorOverlayDimmer!

Inherited properties

Public constructors

<init>

ViewHolder(view: View!)

Constructor for ViewHolder.

Parameters
view View!: The View bound to the Row.

Public methods

getHeaderViewHolder

fun getHeaderViewHolder(): RowHeaderPresenter.ViewHolder!

Returns the view holder for the Row header for this Row.

getOnItemViewClickedListener

fun getOnItemViewClickedListener(): BaseOnItemViewClickedListener<Any!>!

Returns the listener for item click event.

getOnItemViewSelectedListener

fun getOnItemViewSelectedListener(): BaseOnItemViewSelectedListener<Any!>!

Returns the listener for item or row selection.

getOnKeyListener

open fun getOnKeyListener(): OnKeyListener!

Returns the key listener.

getRow

fun getRow(): Row!

Returns the row bound to this ViewHolder. Returns null if the row is not an instance of Row.

Return
Row!: The row bound to this ViewHolder. Returns null if the row is not an instance of Row.

getRowObject

fun getRowObject(): Any!

Returns the Row object bound to this ViewHolder.

Return
Any!: The row object bound to this ViewHolder.

getSelectLevel

fun getSelectLevel(): Float

Returns the current selection level of the Row.

getSelectedItem

open fun getSelectedItem(): Any!

Return currently selected item inside a row ViewHolder.

Return
Any!: The selected item.

getSelectedItemViewHolder

open fun getSelectedItemViewHolder(): Presenter.ViewHolder!

Return ViewHolder of currently selected item inside a row ViewHolder.

Return
Presenter.ViewHolder!: The selected item's ViewHolder.

isExpanded

fun isExpanded(): Boolean

Returns whether the Row is in its expanded state.

Return
Boolean: true if the Row is expanded, false otherwise.

isSelected

fun isSelected(): Boolean

Returns whether the Row is selected.

Return
Boolean: true if the Row is selected, false otherwise.

setActivated

fun setActivated(activated: Boolean): Unit

Sets the row view's activated status. The status will be applied to children through syncActivatedStatus(View). Application should only call this function when RowPresenter#getSyncActivatePolicy() is RowPresenter#SYNC_ACTIVATED_CUSTOM; otherwise the value will be overwritten when expanded or selected status changes.

setOnItemViewClickedListener

fun setOnItemViewClickedListener(listener: BaseOnItemViewClickedListener<Any!>!): Unit

Sets the listener for item click event. RowPresenter does nothing but subclass of RowPresenter may fire item click event if it has the concept of item. OnItemViewClickedListener will override View.OnClickListener that item presenter sets during Presenter#onCreateViewHolder(ViewGroup).

setOnItemViewSelectedListener

fun setOnItemViewSelectedListener(listener: BaseOnItemViewSelectedListener<Any!>!): Unit

Sets the listener for item or row selection. RowPresenter fires row selection event with null item. A subclass of RowPresenter e.g. ListRowPresenter may fire a selection event with selected item.

setOnKeyListener

open fun setOnKeyListener(keyListener: OnKeyListener!): Unit

Sets a key listener.

syncActivatedStatus

fun syncActivatedStatus(view: View!): Unit

Synchronizes the activated status of view to the last value passed through RowPresenter.ViewHolder#setActivated(boolean). No operation if RowPresenter.ViewHolder#setActivated(boolean) is never called. Normally application does not need to call this method, ListRowPresenter automatically calls this method when a child is attached to list row. However if application writes its own custom RowPresenter, it should call this method when attaches a child to the row view.

Properties

mColorDimmer

protected val mColorDimmer: ColorOverlayDimmer!