I created an AlertDialog:
private CharSequence[] _items = { "item1", "item2", "item3", "item4",
"item5", "item6", "item7" };
AlertDialog.Builder daysBuilder = new AlertDialog.Builder(this);
daysBuilder.setTitle("SomeCaption");
daysBuilder.setMultiChoiceItems(_items,new Boolean[] { false, true, false,
false false false, true }, SetListener);
daysBuilder.setPositiveButton("OK", OKListener);
daysBuilder.setNegativeButton("Cancel", CancelListener);
AlertDialog alert = daysBuilder.create();
alert.show();`
Through the statement "new Boolean[] { false, true, false false false false, true }
" the items
in the dialog get checked/unchecked by default.
When I open the dialog, change the selection of the items but then dismiss (by pressing cancel or the back-button of the device) the dialog gets dismissed. So far so good.
But when I reopen the dialog, the items have the checked/unchecked state of the previous changes from the last opening of the dialog.
But when the dialog was dismissed at the first opening, I want to have the items checked/unchecked state like when I created the dialog (new Boolean[] { false, true, false false false false, true }
).
So basically I need an opportunity to get notified when the dialog gets dissmissed so I can then reset the state of the items.
I tried it with the setOnDismissListener for the dialog object. Unfortunately this is just available in API 17.
setOnDismissListener worked perfect for me (exactly what I need) in the emulator (API 17) but not on my device (Android 4.1 => API 16)
Is there something similar in API 16?