Class CarListTemplate
A scrolling list of selectable rows, optionally grouped into CarSections, with an optional
header CarActionStrip. The most common in-car template -- audio browse, POI lists, settings.
Maps to androidx.car.app.model.ListTemplate and CPListTemplate.
Head units enforce a hard row cap (see com.codename1.car.spi.CarBridge#getListRowLimit() /
CarContext#getListRowLimit()); rows beyond the cap are dropped by the platform.
CarListTemplate t = new CarListTemplate().setTitle("Library");
t.addRow(new CarRow("Songs").setBrowsable(true).setOnAction(ctx -> ctx.pushScreen(new SongsScreen())));
t.addRow(new CarRow("Albums").setBrowsable(true).setOnAction(ctx -> ctx.pushScreen(new AlbumsScreen())));
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a row to the template's default (untitled) section, creating it on first use.addSection(CarSection section) Adds a titled section of rows.Returns the header action strip, or null.Returns the sections of this list, in order.booleanReturns true when the list should render a loading spinner instead of content.setHeaderActions(CarActionStrip headerActions) Sets the header action strip (e.g. a refresh or search action).setLoading(boolean loading) Marks the template as loading; the head unit renders a spinner and ignores any rows.Sets the header title.Methods inherited from class CarTemplate
getTitle
-
Constructor Details
-
CarListTemplate
public CarListTemplate()
-
-
Method Details
-
setTitle
Sets the header title.
Parameters
title: the header title
Returns
this template, for chaining
-
addRow
Adds a row to the template's default (untitled) section, creating it on first use. Use
addSection(CarSection)when you need grouped rows.Parameters
row: the row to add
Returns
this template, for chaining
-
addSection
Adds a titled section of rows.
Parameters
section: the section to add
Returns
this template, for chaining
-
getSections
Returns the sections of this list, in order. -
getHeaderActions
Returns the header action strip, or null. -
setHeaderActions
Sets the header action strip (e.g. a refresh or search action).
Parameters
headerActions: the action strip
Returns
this template, for chaining
-
isLoading
public boolean isLoading()Returns true when the list should render a loading spinner instead of content. -
setLoading
Marks the template as loading; the head unit renders a spinner and ignores any rows. Set this while fetching content, then
CarScreen#invalidate()once the rows are ready.Parameters
loading: true to show a spinner
Returns
this template, for chaining
-