I have the following code for an AlertDialog
CheckBox chkLunes,chkMartes,chkMier,chkJue,chkVie,chkSab;
chkLunes=new CheckBox(getActivity());
chkMartes=new CheckBox(getActivity());
chkMier=new CheckBox(getActivity());
chkJue=new CheckBox(getActivity());
chkVie=new CheckBox(getActivity());
chkSab=new CheckBox(getActivity());
chkLunes.setChecked(false);
chkMartes.setChecked(false);
chkMier.setChecked(false);
chkJue.setChecked(false);
chkVie.setChecked(false);
chkSab.setChecked(false);
chkLunes.setText(getString(R.string.Lunes));
chkMartes.setText(getString(R.string.Martes));
chkMier.setText(getString(R.string.Miercoles));
chkJue.setText(getString(R.string.Jueves));
chkVie.setText(getString(R.string.Viernes));
chkSab.setText(getString(R.string.Sabado));
AlertDialog builder=new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.AsignarAsistenciasTituloDialog))
.setMessage(getString(R.string.AsignarAsistenciasMensaje))
.setIcon(R.drawable.ic_dialog_info)
.setView(chkLunes)
.setView(chkMartes)
.setView(chkMier)
.setView(chkJue)
.setView(chkVie)
.setView(chkSab)
.setPositiveButton(getString(R.string.Aceptar), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setNegativeButton(getString(R.string.Cancelar), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).show();
the intention is that all 6 will be displayed checkBox
in the Alertdialog
, but as it stands now, it replaces the chkLunes
until you get to chkSabado
.
how can I get all 6 CheckBoxes to show in my AlertDialog?
I leave you a reference of how my currently looks AlertDialog
to exemplify:
To create a Dialog with multiple choices use setMultiChoiceItems :
You can create a list of elements which receives as a parameter and contains the desired options, Example: