lundi 29 février 2016

return more rhan one value in multiple choice in Android

I have list view with multiple choice items, I want whenever user check more than one item, return all his checked values

SparseBooleanArray checked = lv.getCheckedItemPositions();
            ArrayList<String> selectedItems = new ArrayList<String>();

            for (int i = 0; i < checked.size(); i++) {
             int position = checked.keyAt(i);
             if (checked.valueAt(i))
             selectedItems.add(String.valueOf(ard.getItem(position)));
             }

         String[] outputStrArr = new String[selectedItems.size()];

          for (int i = 0; i < selectedItems.size(); i++) {
              outputStrArr[i] = selectedItems.get(i);
              Pushbots.sharedInstance().setAlias(outputStrArr[i]);

              }



        }
    });

in this case, only last checked value is took ...

Aucun commentaire:

Enregistrer un commentaire