Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

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
open Unit

Sets a key listener.

Any!

Returns the Row object bound to this ViewHolder.

BaseOnItemViewClickedListener<Any!>!

Returns the listener for item click event.

open Any!

Return currently selected item inside a row ViewHolder.

Unit

Sets the listener for item or row selection.

Unit

Sets the listener for item click event.

RowHeaderPresenter.ViewHolder!

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

Boolean

Returns whether the Row is selected.

open Presenter.ViewHolder!

Return ViewHolder of currently selected item inside a row ViewHolder.

Row!

Returns the row bound to this ViewHolder.

Boolean

Returns whether the Row is in its expanded state.

open OnKeyListener!

Returns the key listener.

BaseOnItemViewSelectedListener<Any!>!

Returns the listener for item or row selection.

Float

Returns the current selection level of the Row.

Unit
setActivated(activated: Boolean)

Sets the row view's activated status.

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

setOnKeyListener

open fun setOnKeyListener(keyListener: OnKeyListener!): Unit

Sets a key listener.

getRowObject

fun getRowObject(): Any!

Returns the Row object bound to this ViewHolder.

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

getOnItemViewClickedListener

fun getOnItemViewClickedListener(): BaseOnItemViewClickedListener<Any!>!

Returns the listener for item click event.

getSelectedItem

open fun getSelectedItem(): Any!

Return currently selected item inside a row ViewHolder.

Return
Any!: The selected item.

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.

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).

getHeaderViewHolder

fun getHeaderViewHolder(): RowHeaderPresenter.ViewHolder!

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

isSelected

fun isSelected(): Boolean

Returns whether the Row is selected.

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

getSelectedItemViewHolder

open fun getSelectedItemViewHolder(): Presenter.ViewHolder!

Return ViewHolder of currently selected item inside a row ViewHolder.

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

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.

isExpanded

fun isExpanded(): Boolean

Returns whether the Row is in its expanded state.

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

getOnKeyListener

open fun getOnKeyListener(): OnKeyListener!

Returns the key listener.

getOnItemViewSelectedListener

fun getOnItemViewSelectedListener(): BaseOnItemViewSelectedListener<Any!>!

Returns the listener for item or row selection.

getSelectLevel

fun getSelectLevel(): Float

Returns the current selection level of the Row.

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.

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!