I want to create a way users can select options like the image below

Right now am doing the following
public static class CategoriesDialogFragment extends SherlockDialogFragment {
public static CategoriesDialogFragment newInstance(int title) {
CategoriesDialogFragment frag = new CategoriesDialogFragment();
Bundle args = new Bundle();
args.putInt("title", title);
frag.setArguments(args);
return frag;
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
int title = getArguments().getInt("title");
return new AlertDialog.Builder(getActivity())
.setIcon(R.drawable.alert_dialog_icon)
.setTitle(title)
.setMultiChoiceItems(_categories, _selections,
new DialogSelectionClickHandler())
.setPositiveButton(R.string.alert_dialog_ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
((MainActivity) getActivity())
.doPositiveClick();
}
}).create();
/*
* .setNegativeButton(R.string.alert_dialog_cancel, new
* DialogInterface.OnClickListener() { public void
* onClick(DialogInterface dialog, int whichButton) {
* ((MainActivity) getActivity()) .doNegativeClick(); } })
*/
}
public class DialogSelectionClickHandler implements
DialogInterface.OnMultiChoiceClickListener {
public void onClick(DialogInterface dialog, int clicked,
boolean selected) {
// Log.i("ME", _options[clicked] + " selected: " + selected);
}
}
}
But i want to add ALL option like the image. So i think i will have to build a custom Dialog. Can i still extend the native setMultiChoiceItems so that it will reduce my handling of the code.
You could probably use the
setCustomTitle()method of theAlertDialog.Builderclass and construct your own title which has the title text and also the allCheckBox, something like this:where
R.layout.custom_titleis:Other style tweaks should be made to make it look better.
But seeing the entire dialog layout you may want to go with a custom
Dialogclass, for which thesetMultiChoice()method will not be available(but in the end it will be easy to replicate).