Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

Action

public final class Action
extends Object

java.lang.Object
   ↳ androidx.car.app.model.Action


Represents an action with an optional icon and text.

Actions may be displayed differently depending on the template or model they are added to. For example, the host may decide to display an action as a floating action button (FAB) when displayed over a map, as a button when displayed in a Pane, or as a simple icon with no title when displayed within a Row.

Standard actions

A set of standard, built-in Action instances is available with a few of the common basic actions car apps may need (for example a BACK action).

With the exception of APP_ICON and BACK, an app can provide a custom title and icon for the action. However, depending on the template the action belongs to, the title or icon may be disallowed. If such restrictions apply, the documentation of the APIs that consume the action will note them accordingly.

Summary

Nested classes

class Action.Builder

A builder of Action

Constants

int TYPE_APP_ICON

An action representing an app's icon.

int TYPE_BACK

An action to navigate back in the user interface.

int TYPE_CUSTOM

An app-defined custom action type.

Fields

public static final Action APP_ICON

A standard action to show the app's icon.

public static final Action BACK

A standard action to navigate back in the user interface.

Public methods

boolean equals(Object other)
CarColor getBackgroundColor()

Returns the CarColor used for the background color of the action.

CarIcon getIcon()

Returns the CarIcon to display in the action or null if the action does not have an icon.

OnClickDelegate getOnClickDelegate()

Returns the OnClickDelegate that should be used for this action.

CarText getTitle()

Returns the title displayed in the action or null if the action does not have a title.

int getType()

Returns the type of the action.

int hashCode()
boolean isStandard()

Returns whether the action is a standard action such as BACK.

String toString()
static String typeToString(int type)

Converts the given type into a string representation.

Inherited methods

Constants

TYPE_APP_ICON

public static final int TYPE_APP_ICON

An action representing an app's icon.

See also:

Constant Value: 65538 (0x00010002)

TYPE_BACK

public static final int TYPE_BACK

An action to navigate back in the user interface.

See also:

Constant Value: 65539 (0x00010003)

TYPE_CUSTOM

public static final int TYPE_CUSTOM

An app-defined custom action type.

Constant Value: 1 (0x00000001)

Fields

APP_ICON

public static final Action APP_ICON

A standard action to show the app's icon.

This action is non-interactive.

BACK

public static final Action BACK

A standard action to navigate back in the user interface.

The default behavior for a back press will call ScreenManager.pop().

To override the default behavior, register a OnBackPressedCallback via OnBackPressedDispatcher.addCallback(LifecycleOwner, OnBackPressedCallback), which you can retrieve from CarContext.getOnBackPressedDispatcher().

Public methods

equals

public boolean equals (Object other)

Parameters
other Object

Returns
boolean

getBackgroundColor

public CarColor getBackgroundColor ()

Returns the CarColor used for the background color of the action.

Returns
CarColor

getIcon

public CarIcon getIcon ()

Returns the CarIcon to display in the action or null if the action does not have an icon.

Returns
CarIcon

getOnClickDelegate

public OnClickDelegate getOnClickDelegate ()

Returns the OnClickDelegate that should be used for this action.

Returns
OnClickDelegate

getTitle

public CarText getTitle ()

Returns the title displayed in the action or null if the action does not have a title.

Returns
CarText

getType

public int getType ()

Returns the type of the action.

Returns
int

hashCode

public int hashCode ()

Returns
int

isStandard

public boolean isStandard ()

Returns whether the action is a standard action such as BACK.

Returns
boolean

toString

public String toString ()

Returns
String

typeToString

public static String typeToString (int type)

Converts the given type into a string representation.

Parameters
type int

Returns
String