如何取消选中 AlertDialog 中的项目(setMultiChoiceItems)?
2022-09-03 08:41:26
我想清除选定的项目,当总数达到三个选定的项目时,我正在做如下,但不起作用...
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources().getText(R.string.escolhaArquivosBaixados));
builder.setMultiChoiceItems(items, selected, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
//
int count = 0;
for(int i = 1; i < selected.length; i++){
//
if (selected[i]){
count++;
}
if (count == 3){
//enter here but nothing happens
((AlertDialog) dialog).getListView().setItemChecked(which, false);
break;
}
}
}
});