是否可以在列表中显示具有多项选择功能的警报对话框(禁用项目(行))? 通过选中列表中的“无”选项列表中的所有选项应该被禁用,除非选项“无”,如果我取消选中选项“无”需要再次启用所有项目?安卓系统:带多选项的警报对话框
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
dialogBuilder.setMultiChoiceItems(optionsList,selectionState,new
DialogInterface.OnMultiChoiceListener()
{
@Override
public void onClick(DialogInterface dialog,int which, boolean isChecked){
final AlertDialog alertDialog = (AlertDialog) dialog;
final ListView alertDialogList = alertDialog.getListView();
// Here how to make the items in the list as disabled when None is clicked
// None OPtion is one among in optionsList string array
// A loop to disable all items other than clicked one
for (int position = alertDialogList.getCheckedItemPosition(); position<
alertDialogList.getChildCount; position++)
{
alertDialogList.getChildAt(position).setEnabled(false);
}
}
});
你有试过什么吗? – Lucifer
是的,可能的。 – JiTHiN
Lucifer:我尝试了将Listview Item的Clickable和Enable属性设置为false,但我无法正确禁用警报对话框中的其余行,它将禁用警报对话框中列表中的所有行。 –