I have an Array of Strings String [] products = {"apple", "orange", "banana", "tomato"};
I have created a for loop that runs through the array products and creates a Checkbox and sets for each Checkbox the String of the array in the position that is running in the for loop. Then it adds the checkbox to a Linear Layout.
Once I have created all the checkbox with the different strings from array I need to store in a String the text of the checkboxs that are clicked and checked...
This is my code
private LinearLayout linearLayout;
linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
int i = 0;
String [] products = {"apple", "orange", "banana", "tomato", "cheese", "ham", "sausages"};
for (i=0; i<products.length; i++) {
cb = new CheckBox(getApplicationContext());
cb.setText(products[i]);
linearLayout.addView(cb);
}
//Now i need that when a checkbox is clicked and keeps checked it stores the text value in a concatenated String (concatenates all the checkbox that are clicked)
Aucun commentaire:
Enregistrer un commentaire