Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

belongs to Maven artifact androidx.car:car:1.0.0-alpha5

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

Sets start margin of text the same as TextListItem.setPrimaryActionIcon(int) with useLargeIcon set to true.

int TEXT_START_MARGIN_TYPE_NONE

Sets start margin of text the same as TextListItem.setPrimaryActionNoIcon().

int TEXT_START_MARGIN_TYPE_SMALL

Sets start margin of text the same as TextListItem.setPrimaryActionIcon(int) with useLargeIcon set to false.

Public constructors

SubheaderListItem(Context context, String 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(String text)

Sets the text to be displayed.

void setTextStartMarginType(int type)

Sets the start margin of text.

Protected methods

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

Sets start margin of text the same as TextListItem.setPrimaryActionIcon(int) with useLargeIcon set to true.

Constant Value: 2 (0x00000002)

TEXT_START_MARGIN_TYPE_NONE

public static final int TEXT_START_MARGIN_TYPE_NONE

Sets start margin of text the same as TextListItem.setPrimaryActionNoIcon().

Constant Value: 0 (0x00000000)

TEXT_START_MARGIN_TYPE_SMALL

public static final int TEXT_START_MARGIN_TYPE_SMALL

Sets start margin of text the same as TextListItem.setPrimaryActionIcon(int) with useLargeIcon set to false.

Constant Value: 1 (0x00000001)

Public constructors

SubheaderListItem

public SubheaderListItem (Context context, 
                String text)

Parameters
context Context

text String

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 (String text)

Sets the text to be displayed.

Parameters
text String

setTextStartMarginType

public void setTextStartMarginType (int type)

Sets the start margin of text. Defaults to TEXT_START_MARGIN_TYPE_NONE.

Parameters
type int

Protected methods

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.