I am trying to develop apps compatible to car https://developer.android.com/training/cars . I forked official GitHub samples and successfully run the app https://github.com/android/car-samples/blob/main/car_app_library/showcase/src/main/java/androidx/car/app/samples/showcase/templates/ListTemplateDemoScreen.java. But the problem is 6 items can be displayed in a ListItemTemplate without any problem but I need to display more than 15 items. So if I add more than 6 rows I am getting exception.
I have tried:
ItemList.Builder listBuilder = ItemList.builder();
listBuilder.addItem(
Row.builder()
.setOnClickListener(ParkedOnlyOnClickListener.create(() -> onClick("Parked action")))
.setTitle("Parked Only Title")
.addText("More Parked only text.")
.build());
for (int i = 2; i <= 15; ++i) { //if items < 6 then it works fine
final String onClickText = "Clicked row: " + i;
listBuilder.addItem(
Row.builder()
.setOnClickListener(() -> onClick(onClickText))
.setTitle("Title " + i)
.addText("First line of text")
.addText("Second line of text")
.build());
}
Exception - Caused by: java.lang.IllegalArgumentException: The number of added rows exceeded the supported max of 6
I am using 'com.google.android.libraries.car:car-app:1.0.0-beta.1'
library for development.