public class CarRow

  1. Object
  2. CarRow

A single selectable row in a CarListTemplate. Maps to androidx.car.app.model.Row and to a CPListItem on CarPlay. A row has a primary title, an optional secondary text line, an optional leading image and an activation listener.

CarRow track = new CarRow("Take Five")
        .setText("Dave Brubeck")
        .setImage(albumArt)
        .setOnAction(ctx -> play(trackId));

Constructors

public CarRow()Creates an empty row.
public CarRow(String title)Creates a row with the supplied title.

Methods

public String getTitle()Returns the primary title.
public CarRow setTitle(String title)Sets the primary title.
public String getText()Returns the secondary text line, or null.
public CarRow setText(String text)Sets the secondary text line shown under the title.
public Image getImage()Returns the leading image, or null.
public CarRow setImage(Image image)Sets the leading image (album art, POI thumbnail, icon).
public boolean isBrowsable()Returns true when this row drills into a sub-screen (renders a chevron).
public CarRow setBrowsable(boolean browsable)Marks this row as browsable, i.e. selecting it pushes a deeper CarScreen (the head unit renders a disclosure chevron).
public CarActionListener getOnAction()Returns the activation listener, or null.
public CarRow setOnAction(CarActionListener listener)Sets the listener invoked (on the EDT) when the row is selected.

Inherited methods

Constructor details

CarRow

public CarRow()
Creates an empty row.

CarRow

public CarRow(String title)
Creates a row with the supplied title.

Parameters

title String
the primary line

Method details

getTitle

public String getTitle()
Returns the primary title.

setTitle

public CarRow setTitle(String title)
Sets the primary title.

Parameters

title String
the primary line

Returns

this row, for chaining

getText

public String getText()
Returns the secondary text line, or null.

setText

public CarRow setText(String text)
Sets the secondary text line shown under the title.

Parameters

text String
the secondary line

Returns

this row, for chaining

getImage

public Image getImage()
Returns the leading image, or null.

setImage

public CarRow setImage(Image image)
Sets the leading image (album art, POI thumbnail, icon).

Parameters

image Image
the leading image

Returns

this row, for chaining

isBrowsable

public boolean isBrowsable()
Returns true when this row drills into a sub-screen (renders a chevron).

setBrowsable

public CarRow setBrowsable(boolean browsable)
Marks this row as browsable, i.e. selecting it pushes a deeper CarScreen (the head unit renders a disclosure chevron). Set this for rows whose listener pushes another screen.

Parameters

browsable boolean
true to render a drill-in affordance

Returns

this row, for chaining

getOnAction

public CarActionListener getOnAction()
Returns the activation listener, or null.

setOnAction

public CarRow setOnAction(CarActionListener listener)
Sets the listener invoked (on the EDT) when the row is selected.

Parameters

listener CarActionListener
the activation callback

Returns

this row, for chaining