1

「onCreateDialog」メソッドを使用して、アクティビティからアラート ダイアログを開いています。

protected Dialog onCreateDialog(int id) {
        Dialog dialog = null;
        switch(id) {
        case DIALOG_PASSWORD_VERIFICATION:
            LayoutInflater factory = LayoutInflater.from(this);
            final View passwordDialog = factory.inflate(R.layout.password, null);

            AlertDialog.Builder alert = new AlertDialog.Builder(this);

            alert.setTitle("Please enter your password");
            alert.setView(passwordDialog);
            alert.setCancelable(false);
            alert.create();

            alert.setPositiveButton("Ok", new PasswordDialogListenerOk(
                    passwordDialog, getApplicationContext()));
            alert.setNegativeButton("Cancel", new PasswordDialogListenerOk(
                    passwordDialog, getApplicationContext()));

            alert.show();
            break;
        default:
            dialog = null;
        }
        return dialog;
    }

すべてが正常にスムーズに機能しますが、ACTIVITY に戻る場所がわかりません。ダイアログは消えますが、ダイアログが閉じた後のアクティビティの戻りポイントはどこですか?

4

1 に答える 1

1

アクティビティに戻るための明確な「場所」は実際にはありません。ある時点で行くとOnResume思いますが、ダイアログが閉じられたら何かをしたい場合は、そのコードをリスナーに入れるだけです(この場合はそれを呼び出しましたPasswordDialogListener)。特定の目的で使用したい場合は、何を達成しようとしているのかを説明する必要があります。

于 2012-02-28T21:21:33.673 に答える