CarMenuItem.Builder

public static final class CarMenuItem.Builder
extends Object

java.lang.Object
   ↳ androidx.car.widget.CarMenuItem.Builder


Builder for creating a CarMenuItem

Summary

Public constructors

CarMenuItem.Builder()

Public methods

CarMenuItem build()

Returns a CarMenuItem built with the provided information.

CarMenuItem.Builder setCheckable(boolean checkable)

Sets whether the CarMenuItem is checkable or not.

CarMenuItem.Builder setChecked(boolean checked)

Sets whether the CarMenuItem is checked or not.

CarMenuItem.Builder setDisplayBehavior(CarMenuItem.DisplayBehavior displayBehavior)

Sets the display behavior of the @code CarMenuItem}.

CarMenuItem.Builder setEnabled(boolean enabled)

Sets whether the CarMenuItem is enabled or disabled.

CarMenuItem.Builder setIcon(Icon icon)

Sets the icon of the CarMenuItem.

CarMenuItem.Builder setOnClickListener(CarMenuItem.OnClickListener listener)

Sets CarMenuItem.OnClickListener of the CarMenuItem.

CarMenuItem.Builder setStyle(int styleResId)

Sets the style of the CarMenuItem.

CarMenuItem.Builder setTitle(CharSequence title)

Sets the title of the CarMenuItem.

Inherited methods

Public constructors

CarMenuItem.Builder

public CarMenuItem.Builder ()

Public methods

build

public CarMenuItem build ()

Returns a CarMenuItem built with the provided information.

Returns
CarMenuItem

setCheckable

public CarMenuItem.Builder setCheckable (boolean checkable)

Sets whether the CarMenuItem is checkable or not.

Checkable items are rendered as switch widgets.

Parameters
checkable boolean: true if the CarMenuItem is checkable.

Returns
CarMenuItem.Builder This Builder object to allow call chaining.

setChecked

public CarMenuItem.Builder setChecked (boolean checked)

Sets whether the CarMenuItem is checked or not.

Items are unchecked by default, this has no effect if setCheckable(boolean) is false.

Parameters
checked boolean: true if the CarMenuItem is checked.

Returns
CarMenuItem.Builder This Builder object to allow call chaining.

setDisplayBehavior

public CarMenuItem.Builder setDisplayBehavior (CarMenuItem.DisplayBehavior displayBehavior)

Sets the display behavior of the @code CarMenuItem}. The display behavior determines whether the item is displayed on the Toolbar or in the overflow menu, see CarMenuItem.DisplayBehavior.

Parameters
displayBehavior CarMenuItem.DisplayBehavior: Display behavior of the CarMenuItem.

Returns
CarMenuItem.Builder This Builder object to allow call chaining.

setEnabled

public CarMenuItem.Builder setEnabled (boolean enabled)

Sets whether the CarMenuItem is enabled or disabled.

Items are enabled by default.

Parameters
enabled boolean: true if the CarMenuItem is enabled.

Returns
CarMenuItem.Builder This Builder object to allow call chaining.

setIcon

public CarMenuItem.Builder setIcon (Icon icon)

Sets the icon of the CarMenuItem.

Parameters
icon Icon: Icon of the CarMenuItem.

Returns
CarMenuItem.Builder This Builder object to allow call chaining.

setOnClickListener

public CarMenuItem.Builder setOnClickListener (CarMenuItem.OnClickListener listener)

Sets CarMenuItem.OnClickListener of the CarMenuItem.

Parameters
listener CarMenuItem.OnClickListener: OnClick listener of the CarMenuItem.

Returns
CarMenuItem.Builder This Builder object to allow call chaining.

setStyle

public CarMenuItem.Builder setStyle (int styleResId)

Sets the style of the CarMenuItem.

Parameters
styleResId int: Res Id of the style to be used for the CarMenuItem.

Returns
CarMenuItem.Builder This Builder object to allow call chaining.

setTitle

public CarMenuItem.Builder setTitle (CharSequence title)

Sets the title of the CarMenuItem.

Parameters
title CharSequence: Title of the CarMenuItem.

Returns
CarMenuItem.Builder This Builder object to allow call chaining.