Skip to content Skip to sidebar Skip to footer

Android: Keeping Track Of Checked Values In Multi Select Dialog

I have a button, on click of which i display a multi-select dialog. I load the dialog with values from the database. i wanna track the values in the dialog that are checked. How do

Solution 1:

Make an ArrayList, and while selecting option just add to the list and while unselecting remove it from the list. thats it

ArrayList<String> checkedValue= new ArrayList<String>();


public void onClick( DialogInterface dialog, int clicked, boolean checked )  
{  
      if (isChecked) 
            {
                if(!checkedValue.contains(ser[which]))
                    checkedValue.add(ser[which]);
            } 
            else
            {
              if(checkedValue.contains(ser[which]))
                  checkedValue.remove(ser[which]);
            }

} 

Post a Comment for "Android: Keeping Track Of Checked Values In Multi Select Dialog"