How do you disable a button inside of an AlertDialog?
<p>I am trying to write an AlertDialog that has 3 buttons. I want the middle, Neutral Button to be disabled if a certain condition is not met.</p>

<p>Here is my code:</p>

<pre><code>int playerint = settings.getPlayerInt();
int monsterint = settings.getMonsterInt();



        AlertDialog.Builder alertbox = new AlertDialog.Builder(this);
        alertbox.setMessage("You have Encountered a Monster");

        alertbox.setPositiveButton("Fight!",
                new DialogInterface.OnClickListener() {

                    // do something when the button is clicked
                    public void onClick(DialogInterface arg0, int arg1) {
                        createMonster();
                        fight();

                    }
                });

        alertbox.setNeutralButton("Try to Outwit",
                new DialogInterface.OnClickListener() {

                    // do something when the button is clicked
                    public void onClick(DialogInterface arg0, int arg1) {
                        // This should not be static
//                      createTrivia();
                        trivia();

                    }
                });

        // Return to Last Saved CheckPoint
        alertbox.setNegativeButton("Run Away!",
                new DialogInterface.OnClickListener() {

                    // do something when the button is clicked
                    public void onClick(DialogInterface arg0, int arg1) {
                        runAway();
                    }
                });

        // show the alert box
        alertbox.show();

// Intellect Check

Button button = ((AlertDialog) alertbox).getButton(AlertDialog.BUTTON_NEUTRAL);

        if(monsterint &gt; playerint) {


            button.setEnabled(false);

        }
    }
</code></pre>

<p>The line:     Button button = ((AlertDialog) alertbox).getButton(AlertDialog.BUTTON_NEUTRAL);
 gives the error: Cannot cast from AlertDialog.Builder to 
     AlertDialog</p>

<p>How do I fix this?? What am I doing wrong?</p>
