Skip to content Skip to sidebar Skip to footer

How Check All Checkbox Items In Alertdialog

salam How check all Checkbox items(setMultiChoiceItems) in Android AlertDialog AlertDialog.Builder builder = new AlertDialog.Builder(A); builder.setTitle(A.getString(R.str

Solution 1:

Can it help you?

AlertDialog.Builderbuilder=newAlertDialog.Builder(A);
    builder.setTitle(A.getString(R.string.which_number));
    builder.setIcon(R.drawable.ic_launcher_mini);
    builder.setMultiChoiceItems(line, null,
            newDialogInterface.OnMultiChoiceClickListener() {
                @OverridepublicvoidonClick(DialogInterface dialog, int which,
                                    boolean isChecked) {
                    AlertDialogdialog= (AlertDialog) dialog;
                    ListViewv= dialog.getListView();
                    inti=0;
                    while(i < line.length) {
                        v.setItemChecked(i, check);
                        i++;
                    }
                }
            });

Solution 2:

answer is very simple

the second input parameter of setMultiChoiceItems is default CheckBoxes status

intL= line.length;
    boolean[] b2 = newboolean[L];
    for(int i=0 ; i<L ; i++){
        b2[i]=true;
    }
    builder.setMultiChoiceItems(line, b2,
            newDialogInterface.OnMultiChoiceClickListener() {
                @OverridepublicvoidonClick(DialogInterface dialog, int which,
                                    boolean isChecked) {

Post a Comment for "How Check All Checkbox Items In Alertdialog"