I can display the information of my phone application but I am restricted to display only six.
I would like to know how to proceed to display the rest of the elements ( i have a list of 17 elements).
For the moment I use the first and last columns of my Template to do an invalidate()
and display the previous or next items of my list
public Template onGetTemplate() {
ListTemplate.Builder templateBuilder = new ListTemplate.Builder();
ItemList.Builder sectionABuilder = new ItemList.Builder();
if(compteur < 4 ) {
try {
if (DataMgr.getInstance().getDataListAdress().size() > 0 && compteur < DataMgr.getInstance().getDataListAdress().get(0).length) {
for (int i = compteur; i < compteur + 5; i++) {
System.out.println("////Test + " + DataMgr.getInstance().getDataListAdress().get(0)[i]);
System.out.println("////TestLength + " + DataMgr.getInstance().getDataListAdress().get(0).length);
sectionABuilder.addItem(buildRow(DataMgr.getInstance().getDataListAdress().get(0)[i]));
}
}
sectionABuilder.addItem(buildRowClick("Suivant"));
templateBuilder.addSectionedList(
SectionedItemList.create(sectionABuilder.build(), "Header"));
} catch (Exception e) {
CarToast.makeText(getCarContext(), "No more", CarToast.LENGTH_SHORT).show();
}
} else {
sectionABuilder.addItem(buildRowClickPrecedent("Precedent"));
try {
if (DataMgr.getInstance().getDataListAdress().size() > 0 && compteur < DataMgr.getInstance().getDataListAdress().get(0).length) {
for (int i = compteur; i < compteur + 4; i++) {
System.out.println("////Test + " + DataMgr.getInstance().getDataListAdress().get(0)[i]);
System.out.println("////Test +" + DataMgr.getInstance().getDataListAdress().get(0).length);
sectionABuilder.addItem(buildRow(DataMgr.getInstance().getDataListAdress().get(0)[i]));
}
}
sectionABuilder.addItem(buildRowClick("Suivant"));
templateBuilder.addSectionedList(
SectionedItemList.create(sectionABuilder.build(), "Header"));
} catch (Exception e) {
CarToast.makeText(getCarContext(), "No more", CarToast.LENGTH_SHORT).show();
}
}
return templateBuilder
.setHeaderAction(Action.PAN)
.setTitle("ok")
.build();
}
@NonNull
private Row buildRow(String data) {
return new Row.Builder()
.setTitle(data)
.build();
}
@NonNull
private Row buildRowClick(String data) {
return new Row.Builder()
.setOnClickListener(new OnClickListener() {
@Override
public void onClick() {
compteur += 4;
invalidate();
}
})
.setTitle(data)
.build();
}