且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android的:如何在AlertDialog禁用的CheckBox?

更新时间:2023-10-19 22:03:28

您应该能够在你想在你的onClick()监听器禁用两个复选框调用.setEnabled(假)。出于好奇,你为什么要使用一个for循环结构环通2项,并将其设置为检查。这在我看来,呼吁双方的.setChecked()2连续调用将简化这个proccess。

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样品:

code sample:

//This line has to go after your dialog.show(); call
    CheckBox chkBox = (CheckBox) dialog.findViewById(R.id.yourCheckBox);
//This line will go in your OnClickListener.
    chkBox.setEnabled(false);