Dialogs order in Android

爷,独闯天下 提交于 2019-12-22 01:09:11

问题


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:


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();
        }
    });


来源:https://stackoverflow.com/questions/3989767/dialogs-order-in-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!