I am using the following code from apidemos.
return new AlertDialog.Builder(AlertDialogSamples.this)
.setIcon(R.drawable.ic_popup_reminder)
.setTitle(R.string.alert_dialog_multi_choice)
.setMultiChoiceItems(R.array.select_dialog_items3,
new boolean[]{false, true, false, true, false, false, false},
new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int whichButton,
boolean isChecked) {
}
})
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
})
.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
})
.create();
In /* User clicked Yes so do some stuff */I do not get the variable isChecked. However, I am provided with isChecked in the section /* User clicked on a check box do some stuff */. Obviously, I do not want to update my SharedPrefs when I click on the checkbox if the user hits cancel.
So how do I set checkboxes and values ββin setPositiveButtononClick?
Thank.
source
share