public class CarListTemplate
- Object
- CarTemplate
- 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())));
Constructors
public CarListTemplate() |
Methods
public CarListTemplate setTitle(String title) | Sets the header title. |
public CarListTemplate addRow(CarRow row) | Adds a row to the template’s default (untitled) section, creating it on first use. |
public CarListTemplate addSection(CarSection section) | Adds a titled section of rows. |
public List<CarSection> getSections() | Returns the sections of this list, in order. |
public CarActionStrip getHeaderActions() | Returns the header action strip, or null. |
public CarListTemplate setHeaderActions(CarActionStrip headerActions) | Sets the header action strip (e.g. a refresh or search action). |
public boolean isLoading() | Returns true when the list should render a loading spinner instead of content. |
public CarListTemplate setLoading(boolean loading) | Marks the template as loading; the head unit renders a spinner and ignores any rows. |
Inherited methods
From CarTemplate
Constructor details
CarListTemplate
public CarListTemplate()Method details
setTitle
public CarListTemplate setTitle(String title)Sets the header title.
Parameters
titleString- the header title
Returns
this template, for chaining
addRow
public CarListTemplate addRow(CarRow row)Adds a row to the template’s default (untitled) section, creating it on first use. Use
addSection(CarSection) when you need grouped rows.Parameters
rowCarRow- the row to add
Returns
this template, for chaining
addSection
public CarListTemplate addSection(CarSection section)Adds a titled section of rows.
Parameters
sectionCarSection- the section to add
Returns
this template, for chaining
getSections
public List<CarSection> getSections()Returns the sections of this list, in order.
getHeaderActions
public CarActionStrip getHeaderActions()Returns the header action strip, or null.
setHeaderActions
public CarListTemplate setHeaderActions(CarActionStrip headerActions)Sets the header action strip (e.g. a refresh or search action).
Parameters
headerActionsCarActionStrip- 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
public CarListTemplate setLoading(boolean loading)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
loadingboolean- true to show a spinner
Returns
this template, for chaining