SubheaderListItem

open class SubheaderListItem : ListItem<SubheaderListItem.ViewHolder!>
kotlin.Any
   ↳ androidx.car.widget.ListItem<androidx.car.widget.SubheaderListItem.ViewHolder>
   ↳ androidx.car.widget.SubheaderListItem

Class to build a sub-header list item.

A sub-header list item consists of a one-line text. Its margin can be adjusted to match the rest of ListItem through setTextStartMarginType(int).

Summary

Nested classes

Holds views of SubHeaderListItem.

Constants

static Int

A large starting margin before the subheader text.

static Int

No starting margin before the subheader text.

static Int

A small starting margin before the subheader text.

Public constructors

<init>(@NonNull context: Context, @NonNull text: CharSequence)

Public methods

open static SubheaderListItem.ViewHolder
createViewHolder(itemView: View!)

Creates a SubheaderListItem.ViewHolder.

open Int

Used by ListItemAdapter to choose layout to inflate for view holder.

open Unit
setEnabled(enabled: Boolean)

open Unit
setText(@NonNull text: CharSequence)

Sets the text to be displayed; cannot be null or empty string.

open Unit

Sets the start margin of text.

Protected methods

open Context

open Unit

Applies ViewBinders to adjust view layout params.

open Unit

Calculates layout params for views in ViewHolder.

Inherited functions

Constants

TEXT_START_MARGIN_TYPE_LARGE

static val TEXT_START_MARGIN_TYPE_LARGE: Int

A large starting margin before the subheader text.

Value: 2

TEXT_START_MARGIN_TYPE_NONE

static val TEXT_START_MARGIN_TYPE_NONE: Int

No starting margin before the subheader text.

Value: 0

TEXT_START_MARGIN_TYPE_SMALL

static val TEXT_START_MARGIN_TYPE_SMALL: Int

A small starting margin before the subheader text.

Value: 1

Public constructors

<init>

SubheaderListItem(@NonNull context: Context, @NonNull text: CharSequence)

Public methods

createViewHolder

@NonNull open static fun createViewHolder(itemView: View!): SubheaderListItem.ViewHolder

Creates a SubheaderListItem.ViewHolder.

getViewType

open fun getViewType(): Int

Used by ListItemAdapter to choose layout to inflate for view holder.

Return
Int: type of this ListItem.

setEnabled

open fun setEnabled(enabled: Boolean): Unit

setText

open fun setText(@NonNull text: CharSequence): Unit

Sets the text to be displayed; cannot be null or empty string.

setTextStartMarginType

open fun setTextStartMarginType(type: Int): Unit

Sets the start margin of text. Defaults to TEXT_START_MARGIN_TYPE_NONE.

Protected methods

getContext

@NonNull protected open fun getContext(): Context

onBind

protected open fun onBind(viewHolder: SubheaderListItem.ViewHolder!): Unit

Applies ViewBinders to adjust view layout params.

resolveDirtyState

protected open fun resolveDirtyState(): Unit

Calculates layout params for views in ViewHolder.