dimanche 30 septembre 2018

Android: Dynamic number of CheckBoxes for each Row in a ListView

My app shows a listview with a textview and checkbox for each row. The textview contains different types of food. Each row has one checkbox. I want to change that. Each type of food has an attribute called "numberOfPortions“. This number should determine the number of checkboxes in the row. For example: ListItem Beans numberOfPortions = 3 This means that the row in my listview with beans should have 3 checkboxes instead of previously 1 checkbox. How can I achieve that? If I add three checkboxes to my row layout, three checkboxes will be shown in each row, but there are also rows were numberOfPortions is 1 or 2 so that only one or two checkboxes should be shown.

This image shows how my list should look like: https://i.stack.imgur.com/GxV0k.png




Aucun commentaire:

Enregistrer un commentaire