public class CarGridTemplate

  1. Object
  2. CarTemplate
  3. CarGridTemplate
A grid of image-forward CarGridItems – browse categories, station presets, playlist artwork. Maps to androidx.car.app.model.GridTemplate and CPGridTemplate (which itself caps the grid, typically at eight buttons; see CarContext#getGridItemLimit()).

Constructors

public CarGridTemplate()

Methods

public CarGridTemplate setTitle(String title)Sets the header title.
public CarGridTemplate addItem(CarGridItem item)Adds an item to the grid.
public List<CarGridItem> getItems()Returns the grid items, in order.
public CarActionStrip getHeaderActions()Returns the header action strip, or null.
public CarGridTemplate setHeaderActions(CarActionStrip headerActions)Sets the header action strip.
public boolean isLoading()Returns true when the grid should render a loading spinner instead of content.
public CarGridTemplate setLoading(boolean loading)Marks the template as loading; the head unit renders a spinner.

Inherited methods

Constructor details

CarGridTemplate

public CarGridTemplate()

Method details

setTitle

public CarGridTemplate setTitle(String title)
Sets the header title.

Parameters

title String
the header title

Returns

this template, for chaining

addItem

public CarGridTemplate addItem(CarGridItem item)
Adds an item to the grid.

Parameters

item CarGridItem
the grid item to add

Returns

this template, for chaining

getItems

public List<CarGridItem> getItems()
Returns the grid items, in order.

getHeaderActions

public CarActionStrip getHeaderActions()
Returns the header action strip, or null.

setHeaderActions

public CarGridTemplate setHeaderActions(CarActionStrip headerActions)
Sets the header action strip.

Parameters

headerActions CarActionStrip
the action strip

Returns

this template, for chaining

isLoading

public boolean isLoading()
Returns true when the grid should render a loading spinner instead of content.

setLoading

public CarGridTemplate setLoading(boolean loading)
Marks the template as loading; the head unit renders a spinner.

Parameters

loading boolean
true to show a spinner

Returns

this template, for chaining