Action.Builder
public
static
class
Action.Builder
extends Object
java.lang.Object | |
↳ | com.google.android.libraries.car.app.model.Action.Builder |
A builder of Action
.
Summary
Public methods | |
---|---|
Action
|
build()
Constructs the |
Action.Builder
|
setBackgroundColor(CarColor backgroundColor)
Sets the background color to be used for the action. |
Action.Builder
|
setIcon(CarIcon icon)
Sets the icon to display in the action, or |
Action.Builder
|
setOnClickListener(OnClickListener listener)
Sets the |
Action.Builder
|
setTitle(CharSequence title)
Sets the title to display in the action, or |
Inherited methods | |
---|---|
Public methods
build
public Action build ()
Constructs the Action
defined by this builder.
Returns | |
---|---|
Action |
Throws | |
---|---|
IllegalStateException |
if the action is not a standard action and does not have an icon or a title. |
IllegalStateException |
if a listener is set on either Action.APP_ICON or Action.BACK . |
IllegalStateException |
if an icon or title is set on either Action.APP_ICON or
Action.BACK .
|
setBackgroundColor
public Action.Builder setBackgroundColor (CarColor backgroundColor)
Sets the background color to be used for the action.
Requirements
The host may ignore this color and use the default instead if the color does not pass the contrast requirements.
Parameters | |
---|---|
backgroundColor |
CarColor : the CarColor to set as background. Use CarColor.DEFAULT to let the host pick a default. |
Returns | |
---|---|
Action.Builder |
Throws | |
---|---|
IllegalArgumentException |
if backgroundColor is not a standard color. |
NullPointerException |
if backgroundColor is null .
|
setIcon
public Action.Builder setIcon (CarIcon icon)
Sets the icon to display in the action, or null
to not display an icon.
Icons can't be set in standard actions.
Icon Sizing Guidance
The provided icon should have a maximum size of 36 x 36 dp. If the icon exceeds this maximum size in either one of the dimensions, it will be scaled down to be centered inside the bounding box while preserving the aspect ratio.See CarIcon
for more details related to providing icon and image resources that
work with different car screen pixel densities.
Parameters | |
---|---|
icon |
CarIcon |
Returns | |
---|---|
Action.Builder |
setOnClickListener
public Action.Builder setOnClickListener (OnClickListener listener)
Sets the OnClickListener
to call when the action is clicked.
Parameters | |
---|---|
listener |
OnClickListener |
Returns | |
---|---|
Action.Builder |
setTitle
public Action.Builder setTitle (CharSequence title)
Sets the title to display in the action, or null
to not display a title.
The title of a standard action can be set with this method. Actions, including standard actions, don't have a title by default.
Parameters | |
---|---|
title |
CharSequence |
Returns | |
---|---|
Action.Builder |