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

SubheaderListItem

public class SubheaderListItem
extends ListItem<SubheaderListItem.ViewHolder>

java.lang.Object
   ↳ 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

@interface SubheaderListItem.TextStartMarginType

 

class SubheaderListItem.ViewHolder

Holds views of SubHeaderListItem. 

Constants

int TEXT_START_MARGIN_TYPE_LARGE

A large starting margin before the subheader text.

int TEXT_START_MARGIN_TYPE_NONE

No starting margin before the subheader text.

int TEXT_START_MARGIN_TYPE_SMALL

A small starting margin before the subheader text.

Public constructors

SubheaderListItem(Context context, CharSequence text)

Public methods

static SubheaderListItem.ViewHolder createViewHolder(View itemView)

Creates a SubheaderListItem.ViewHolder.

int getViewType()

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

void setEnabled(boolean enabled)

Sets the enabled state of the bound ListItem.ViewHolder.

void setText(CharSequence text)

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

void setTextStartMarginType(int type)

Sets the start margin of text.

Protected methods

Context getContext()
void onBind(SubheaderListItem.ViewHolder viewHolder)

Applies ViewBinders to adjust view layout params.

void resolveDirtyState()

Calculates layout params for views in SubheaderListItem.ViewHolder.

Inherited methods

Constants

TEXT_START_MARGIN_TYPE_LARGE

public static final int TEXT_START_MARGIN_TYPE_LARGE

A large starting margin before the subheader text.

Constant Value: 2 (0x00000002)

TEXT_START_MARGIN_TYPE_NONE

public static final int TEXT_START_MARGIN_TYPE_NONE

No starting margin before the subheader text.

Constant Value: 0 (0x00000000)

TEXT_START_MARGIN_TYPE_SMALL

public static final int TEXT_START_MARGIN_TYPE_SMALL

A small starting margin before the subheader text.

Constant Value: 1 (0x00000001)

Public constructors

SubheaderListItem

public SubheaderListItem (Context context, 
                CharSequence text)

Parameters
context Context

text CharSequence

Public methods

createViewHolder

public static SubheaderListItem.ViewHolder createViewHolder (View itemView)

Creates a SubheaderListItem.ViewHolder.

Parameters
itemView View

Returns
SubheaderListItem.ViewHolder

getViewType

public int getViewType ()

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

Returns
int type of this ListItem.

setEnabled

public void setEnabled (boolean enabled)

Sets the enabled state of the bound ListItem.ViewHolder.

All visible children views of ViewHolder should be set to enabled. Caller is responsible for notifying ListItemAdapter about data change.

Disabled items are usually styled at 50% opacity. Consider similar styling for consistency.

Parameters
enabled boolean

setText

public void setText (CharSequence text)

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

Parameters
text CharSequence

setTextStartMarginType

public void setTextStartMarginType (int type)

Sets the start margin of text. Defaults to TEXT_START_MARGIN_TYPE_NONE.

Parameters
type int

Protected methods

getContext

protected Context getContext ()

Returns
Context

onBind

protected void onBind (SubheaderListItem.ViewHolder viewHolder)

Applies ViewBinders to adjust view layout params.

Parameters
viewHolder SubheaderListItem.ViewHolder

resolveDirtyState

protected void resolveDirtyState ()

Calculates layout params for views in SubheaderListItem.ViewHolder.