Description: The M3 Catalog app contains several List examples. The number of list items in these examples is static. However, there are use cases, where the number of items is dynamic. Consider the following example:
i=0;
listData.add(new CustomListItemData("Item A", i++, 20));
listData.add(new CustomListItemData("Item B", i++, 20));
if (x=y) {
listData.add(new CustomListItemData("Item X", i++, 20));
listData.add(new CustomListItemData("Item Y", i++, 20));
}
listData.add(new CustomListItemData("Item C", i++, 20));
listData.add(new CustomListItemData("Item D", i , 20));
In this case, we can set indexInSection for each item by incrementing an integer variable (i++) that starts at 0. However, when starting to populate the above listData array, it's not yet known how many items the final list will contain. It can be either 4 or 6. So, it's unclear to me what numbers have to be added for sectionCount for each item.
Requirement: How should we handle such a use case when using a List with a dynamic number of items (sectionCount)?
Description: The M3 Catalog app contains several
Listexamples. The number of list items in these examples is static. However, there are use cases, where the number of items is dynamic. Consider the following example:In this case, we can set
indexInSectionfor each item by incrementing an integer variable (i++) that starts at 0. However, when starting to populate the abovelistDataarray, it's not yet known how many items the final list will contain. It can be either 4 or 6. So, it's unclear to me what numbers have to be added forsectionCountfor each item.Requirement: How should we handle such a use case when using a
Listwith a dynamic number of items (sectionCount)?