2

Android アプリケーションを開発していますが、次のような問題があります。

私はこの方法を持っています:

// User has introduced an incorrect password.
private void invalidPassword()
{
    // R.id.string value for alert dialog title.
    int dialogTitle = 0;
    // R.id.string value for alert dialog message.
    int dialogMessage = 0;
    boolean hasReachedMaxAttempts;

    clearWidgets();
    numIntents++;
    hasReachedMaxAttempts = (numIntents > maxNumIntents);

    // Max attempts reached
    if (hasReachedMaxAttempts)
    {
        dialogTitle = R.string.dialog_title_error;
        dialogMessage = R.string.dialog_message_max_attempts_reached;
    }
    else
    {
        dialogTitle = R.string.dialog_title_error;
        dialogMessage = R.string.dialog_message_incorrect_password;
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(dialogMessage)
           .setTitle(dialogTitle);
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
    {
           public void onClick(DialogInterface dialog, int id)
           {
               // TODO: User clicked OK button
               if (hasReachedMaxAttempts)
               {
               }
               else
               {
               }
           }
       });

    AlertDialog dialog = builder.create();
    dialog.show();
}

boolean hasReachedMaxAttempts;内部を可視化するにはどうすればよいonClickですか?

4

3 に答える 3