How do you disable a button inside of an AlertDialog? Follow Up Question

后端 未结 4 494
北海茫月
北海茫月 2021-01-29 07:56

I asked this question yesterday (http://stackoverflow.com/questions/7392321/how-do-you-disable-a-button-inside-of-an-alertdialog) and modified my code accordingly... this mornin

4条回答
  •  隐瞒了意图╮
    2021-01-29 08:50

    The trick is that you need to use the AlertDialog object retuned by AlertDialog.Builder.show() method. No need to call AlertDialog.Builder.create().

    Example:

            AlertDialog dialog = alertbox.show();
            if(monsterint > playerint) {
                Button button = dialog.getButton(AlertDialog.BUTTON_NEUTRAL);
                button.setEnabled(false);
            }
    

提交回复
热议问题