DrawerItemViewHolder

public class DrawerItemViewHolder
extends RecyclerView.ViewHolder implements OnUxRestrictionsChangedListener

java.lang.Object
   ↳ androidx.recyclerview.widget.RecyclerView.ViewHolder
     ↳ androidx.car.drawer.DrawerItemViewHolder


Re-usable RecyclerView.ViewHolder for displaying items in the CarDrawerAdapter.

Summary

Inherited fields

Public constructors

DrawerItemViewHolder(View view)

Create a new ViewHolder that will parse the given view that is meant to displaying items in a drawer.

Public methods

TextView getBodyView()

Returns the view that is used for the body text that is smaller than the title text and appears beneath the title.

ImageView getEndIconView()

Returns the icon that is displayed at the end of the view.

ImageView getIconView()

Returns the view that should be used to display the main icon.

TextView getTitleView()

Returns the view that will display the main title.

void onUxRestrictionsChanged(CarUxRestrictions restrictionsInfo)

Updates child views with current car UX restrictions.

Inherited methods

Public constructors

DrawerItemViewHolder

public DrawerItemViewHolder (View view)

Create a new ViewHolder that will parse the given view that is meant to displaying items in a drawer.

The given view is required to have a title and icon view with an optional body and end icon view. These views are looked up via ids, specifically:

  • Icon - R.id.icon
  • Title - R.id.title
  • Body - R.id.body
  • End Icon - R.id.end_icon

This method is exposed for testing purposes. The DrawerItemViewHolder is automatically created by the CarDrawerAdapter.

Parameters
view View: The view that will represent an item in a drawer.

Public methods

getBodyView

public TextView getBodyView ()

Returns the view that is used for the body text that is smaller than the title text and appears beneath the title.

Returns
TextView

getEndIconView

public ImageView getEndIconView ()

Returns the icon that is displayed at the end of the view.

Returns
ImageView

getIconView

public ImageView getIconView ()

Returns the view that should be used to display the main icon.

Returns
ImageView

getTitleView

public TextView getTitleView ()

Returns the view that will display the main title.

Returns
TextView

onUxRestrictionsChanged

public void onUxRestrictionsChanged (CarUxRestrictions restrictionsInfo)

Updates child views with current car UX restrictions.

Text might be truncated to meet length limit required by regulation.

Parameters
restrictionsInfo CarUxRestrictions: current car UX restrictions.