CarMenuItem
public
class
CarMenuItem
extends Object
| java.lang.Object | |
| ↳ | androidx.car.widget.CarMenuItem |
Class to build a CarMenuItem that appears in the CarToolbar menu.
The following properties can be specified:
- Title - Primary text that is shown on the item.
CarMenuItem.OnClickListener- Listener that handles the clicks on the item.- Icon - An
Iconshown before the title, if the item is not checkable (a switch). - Style - A Resource Id that specifies the style of the item if it's not an overflow item.
- Enabled - A boolean that specifies whether the item is enabled or disabled.
- Checkable - A boolean that specifies whether the item is checkable (a switch) or not.
- Checked - A boolean that specifies whether the item is currently checked or not.
- DisplayBehavior - A
CarMenuItem.DisplayBehaviorthat specifies where the item is displayed.
Properties such as the title, isEnabled, and isChecked can be modified after creation, and as such, have setters in the class and the builder.
Summary
Nested classes | |
|---|---|
class |
CarMenuItem.Builder
Builder for creating a |
enum |
CarMenuItem.DisplayBehavior
Display behaviors for |
interface |
CarMenuItem.OnClickListener
Interface definition for a callback to be invoked when a |
Public methods | |
|---|---|
CarMenuItem.DisplayBehavior
|
getDisplayBehavior()
Returns The |
Icon
|
getIcon()
Returns the icon of the |
CarMenuItem.OnClickListener
|
getOnClickListener()
Returns the |
int
|
getStyleResId()
Returns the Res Id of the |
CharSequence
|
getTitle()
Returns the title of the |
boolean
|
isCheckable()
Returns |
boolean
|
isChecked()
Returns |
boolean
|
isEnabled()
Returns |
void
|
setChecked(boolean checked)
Sets whether the |
void
|
setEnabled(boolean enabled)
Sets whether the |
void
|
setTitle(CharSequence title)
Sets the title of the |
Inherited methods | |
|---|---|
Public methods
getDisplayBehavior
public CarMenuItem.DisplayBehavior getDisplayBehavior ()
Returns The CarMenuItem.DisplayBehavior of the CarMenuItem.
| Returns | |
|---|---|
CarMenuItem.DisplayBehavior |
|
getOnClickListener
public CarMenuItem.OnClickListener getOnClickListener ()
Returns the CarMenuItem.OnClickListener of the CarMenuItem.
| Returns | |
|---|---|
CarMenuItem.OnClickListener |
|
getStyleResId
public int getStyleResId ()
Returns the Res Id of the CarMenuItem's style.
| Returns | |
|---|---|
int |
|
getTitle
public CharSequence getTitle ()
Returns the title of the CarMenuItem.
| Returns | |
|---|---|
CharSequence |
|
isCheckable
public boolean isCheckable ()
Returns true if the CarMenuItem is checkable.
| Returns | |
|---|---|
boolean |
|
isChecked
public boolean isChecked ()
Returns true if the CarMenuItem is checked.
| Returns | |
|---|---|
boolean |
|
isEnabled
public boolean isEnabled ()
Returns true if the CarMenuItem is enabled.
| Returns | |
|---|---|
boolean |
|
setChecked
public void setChecked (boolean checked)
Sets whether the CarMenuItem is checked or not.
This method will only have an effect if this CarMenuItem was built
with CarMenuItem.Builder.setCheckable(boolean) set to true.
| Parameters | |
|---|---|
checked |
boolean: true if the CarMenuItem is checked.
|
setEnabled
public void 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.
|
setTitle
public void setTitle (CharSequence title)
Sets the title of the CarMenuItem.
| Parameters | |
|---|---|
title |
CharSequence: Title of the CarMenuItem.
|
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.