samedi 16 mai 2020

How to get the selected text, not its position in an AlertDialog with MultiChoiceItems

I implemented the google example about alertDialog with multichoititem, in this part of the code it adds the index of the item selected by the user:

if (isChecked) {
                       // If the user checked the item, add it to the selected items
                       selectedItems.add(which);
                   } else if (selectedItems.contains(which)) {
                       // Else, if the item is already in the array, remove it
                       selectedItems.remove(Integer.valueOf(which));
                   }

But, this arraylist selectedItems just have the "positions" of the selected item, which is not very useful, because we usually want the value that the user selected in text (the value of the field, not its position in the list), what I tried was: ((AlertDialog) dialog).getListView()... but the methods listed here do not clarify my idea of obtaining the text of the selected fields, and not their position




Aucun commentaire:

Enregistrer un commentaire