Action.Builder
public
static
final
class
Action.Builder
extends Object
java.lang.Object | |
↳ | androidx.car.app.model.Action.Builder |
A builder of Action
.
Summary
Public constructors | |
---|---|
Builder()
Creates an empty |
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. |
Action.Builder
|
setOnClickListener(OnClickListener listener)
Sets the |
Action.Builder
|
setTitle(CharSequence title)
Sets the title to display in the action. |
Action.Builder
|
setTitle(CarText title)
Sets the title to display in the action. |
Inherited methods | |
---|---|
Public constructors
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, if a listener is set on either
Action.APP_ICON or Action.BACK , or 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.
Note the color of the text cannot be specified. Host implementations may pick the dark or light versions of the given background color as needed.
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.
Unless set with this method, the action will not have an icon.
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 |
Throws | |
---|---|
NullPointerException |
if icon is null
|
setOnClickListener
public Action.Builder setOnClickListener (OnClickListener listener)
Sets the OnClickListener
to call when the action is clicked.
Unless set with this method, the action will not have a click listener.
Note that the listener relates to UI events and will be executed on the main thread
using Looper.getMainLooper()
.
Parameters | |
---|---|
listener |
OnClickListener |
Returns | |
---|---|
Action.Builder |
Throws | |
---|---|
NullPointerException |
if listener is null
|
setTitle
public Action.Builder setTitle (CharSequence title)
Sets the title to display in the action.
Spans are not supported in the input string.
Parameters | |
---|---|
title |
CharSequence |
Returns | |
---|---|
Action.Builder |
Throws | |
---|---|
NullPointerException |
if title is null |
See also:
setTitle
public Action.Builder setTitle (CarText title)
Sets the title to display in the action.
Spans are not supported in the input string.
Parameters | |
---|---|
title |
CarText |
Returns | |
---|---|
Action.Builder |
Throws | |
---|---|
NullPointerException |
if title is null |
See also: