I am using DialogFragment with multichoice checkboxes to allow the user to pick a number of options. I have a Hashmap to which selections are added or removed depending on whether on item is selected when it is clicked - see below. This works fine.
When the user re-opens the Fragment the state of the Dialog is preserved and the items that were previously checked are shown as expected - good so far. However I'd like to know how to read the state of these and add them to my HashMap so that they are returned along with any that are picked up by Listener class. I'm sure this is simple, but I can't find an example.
I've had a look through the API Reference but I can't find an obvious method that provides this.
Thanks in advance.
public class DialogSelectionClickHandler implements
DialogInterface.OnMultiChoiceClickListener {
public void onClick(DialogInterface dialog, int clicked,
boolean selected) {
if (selected) {
// write to a hashmap
groupSelectHash.put(groups[clicked].toString(), "");
}
else
{
// remove from hashmap
groupSelectHash.remove(groups[clicked].toString());
}
Log.i( "DialogTest", "groupSelectHash" + groupSelectHash.toString());
}
}