【问题标题】:show alertDialog after a progress dialog在进度对话框后显示 alertDialog
【发布时间】:2014-05-03 22:48:21
【问题描述】:

我制作了一个应用程序,其中一个活动有一个进度对话框。当进度对话框完成时,我想显示一个警报对话框。 我该怎么做?

请指导我...

谢谢。

【问题讨论】:

  • 好吧,首先添加您的代码,其次您可以在关闭进度对话框时显示警报,或者您可以使用 setOnDismissListener(...)

标签: android dialog


【解决方案1】:

我假设您已经知道如何显示进度对话框。进度对话框有两个监听器,onDismiss 和 onCancel。看看这里的区别:What is the difference between a dialog being dismissed or canceled in Android?

您可以根据自己的要求选择放置任一侦听器。这是一个示例代码。

progressDialog.setOnDismissListener(new OnDismissListener() {
    @Override
    public void onDismiss(DialogInterface dialog) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
            context);

        // set title
        alertDialogBuilder.setTitle("Your Title");

        // set dialog message
        alertDialogBuilder
            .setMessage("Message")
            .setCancelable(false)
            .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                }
              })
            .setNegativeButton("No",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                }
            });

            // create alert dialog
            AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();
        }
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多