Dialogs order in Android

2019-04-17 12:51发布

is there something like dialog's order in Android?

I explain what I mean.

There is a dialog builder with "OK"-Button. When user press ok, dialog will be closed.

Wenn I call more than one dialogs after each other in an activity, I see first the last one, then next to last and so on. But I would like to see first the first dialog, then the second, then ...

Is there the possibility for that?

Or is it possible not to call second dialog until first dialog isn't closed?

Mur

1条回答
戒情不戒烟
2楼-- · 2019-04-17 13:33

When you define the onClick() method for your dialog's "Ok" button (setNeutralButton()), you'll have to display the second dialog (via showDialog() or similar) and then dismiss the first dialog.

An example:

builder = new Builder(context);
builder
    .setTitle(R.string.dialog_download_failed_title)
    .setMessage(R.string.dialog_download_failed_message)
    .setCancelable(true)
    .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            showDialog(SECOND_DIALOG);
            dialog.dismiss();
        }
    });
查看更多
登录 后发表回答