public final class

Action.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.model.Action.Builder

Overview

A builder of Action.

Summary

Constructors
publicBuilder()

Creates an empty Action.Builder instance.

publicBuilder(Action action)

Returns a Action.Builder instance configured with the same data as the given Action instance.

Methods
public Actionbuild()

Constructs the Action defined by this builder.

public Action.BuildersetBackgroundColor(CarColor backgroundColor)

Sets the background color to be used for the action.

public Action.BuildersetEnabled(boolean enabled)

Sets the initial enabled state for Action.

public Action.BuildersetFlags(int flags)

Sets flags affecting how this action should be treated.

public Action.BuildersetIcon(CarIcon icon)

Sets the icon to display in the action.

public Action.BuildersetOnClickListener(OnClickListener listener)

Sets the OnClickListener to call when the action is clicked.

public Action.BuildersetTitle(CarText title)

Sets the title to display in the action, with support for multiple length variants.

public Action.BuildersetTitle(java.lang.CharSequence title)

Sets the title to display in the action.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates an empty Action.Builder instance.

public Builder(Action action)

Returns a Action.Builder instance configured with the same data as the given Action instance.

Methods

public Action.Builder setTitle(java.lang.CharSequence title)

Sets the title to display in the action.

Support for text spans depends on where the action is used. See the documentation of the specific APIs taking an Action for details.

public Action.Builder setTitle(CarText title)

Sets the title to display in the action, with support for multiple length variants.

Support for text spans depends on where the action is used. For example, most templates taking an action support ForegroundCarColorSpan, but this may vary. See the documentation of the specific APIs taking an Action for details.

See also: CarText

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

To minimize scaling artifacts across a wide range of car screens, apps should provide icons targeting a 88 x 88 dp bounding box. 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 its aspect ratio.

See CarIcon for more details related to providing icon and image resources that work with different car screen pixel densities.

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 .

public Action.Builder setBackgroundColor(CarColor backgroundColor)

Sets the background color to be used for the action.

Requirements

Depending on contrast requirements, capabilities of the vehicle screens, or other factors, the color may be ignored by the host or overridden by the vehicle system. See the documentation on where the Action is added for more details on any other restriction(s) that might apply.

Parameters:

backgroundColor: the CarColor to set as background. Use CarColor.DEFAULT to let the host pick a default

public Action.Builder setEnabled(boolean enabled)

Sets the initial enabled state for Action.

The default state of a Action is enabled.

public Action.Builder setFlags(int flags)

Sets flags affecting how this action should be treated.

public Action build()

Constructs the Action defined by this builder.