Action
public
final
class
Action
extends Object
java.lang.Object | |
↳ | com.google.android.libraries.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-inAction
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 |
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 | |
---|---|
static
Action.Builder
|
builder()
Constructs a new builder of |
boolean
|
equals(Object other)
|
int
|
hashCode()
|
Action.Builder
|
newBuilder()
Returns a |
String
|
toString()
|
Inherited methods | |
---|---|
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
builder
public static Action.Builder builder ()
Constructs a new builder of Action
.
Returns | |
---|---|
Action.Builder |
hashCode
public int hashCode ()
Returns | |
---|---|
int |
newBuilder
public Action.Builder newBuilder ()
Returns a Action.Builder
instance configured with the same data as this Action
instance.
Returns | |
---|---|
Action.Builder |
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.
Last updated 2020-10-15 UTC.