Is there a way to get some infomation about the checked items in the next Alert.Builder? I need to save some booleans in SharedPreferences when somebody clicked the positive button. Those booleans are from the choices the user made in the alert. How can I get them?
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final SharedPreferences preferences = getSharedPreferences("type_settings", MODE_PRIVATE);
boolean[] selectedTypes = getSelectedTypes(preferences);
builder.setIcon(R.drawable.menu_type)
.setTitle(R.string.list_dialog_title)
.setMultiChoiceItems(R.array.select_type_items, selectedTypes,
new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) {
}
})
.setPositiveButton(R.string.types_save, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
SharedPreferences.Editor prefEditor = preferences.edit();
}
})
.setNegativeButton(R.string.types_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
})
.create();
builder.show();
I managed to resolve the problem in some way, but i don’t know if it’s a good practice. Here is the code: