Ok guys…I need to create a Alert dialog with 3 check boxes. If the top check box is clicked, 2 another one should be clicked and disabled !! I do them clicked, but not disabled. And i have no idea how to do that.
@Override
protected Dialog onCreateDialog (int id) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("AA");
builder.setMultiChoiceItems(mStrings, mCheckedItems, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(final DialogInterface dialog, int which, boolean isChecked) {
switch (which) {
case 0: {
if(isChecked==true) {
for (int i = 1; i<=2; i++) {
((AlertDialog) dialog).getListView().setItemChecked(i, true);
}
}
if (isChecked==false) {
for (int i = 1; i<=2; i++) {
((AlertDialog) dialog).getListView().setItemChecked(i, false);
}
break;
}
And this solution is not good to. Some times its not click all checkboxes. Have anybody any idea ?
You should be able to call .setEnabled(false) on the two checkboxes you want to disable in your onClick() listener. Out of curiosity why are you using a for loop structure to loop thru 2 items and set them to checked. It seems to me that calling .setChecked() on both of the in 2 successive calls would simplify this proccess.
code sample: