另一个对话框中的对话问题

时间:2010-12-26 16:40:09

标签: android recursion dialog progressdialog

在下载数据时,我会显示带有取消按钮的progressdialog。如果按下,则会弹出alertDialog以进行验证。如果确定,则取消下载并且两个对话框都消失。但是如果用户否定取消,那么两个对话框都会显示出来。这是非常糟糕的,因为它误导用户假设下载完成。我想要的是,progressDialog仍然在屏幕上,直到下载真的完成。有什么想法吗?

以下是我使用的代码:

ProgressDialog makeProgressDialog() {
    ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("downloading, please wait...");
    progressDialog.setCancelable(false);

    progressDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "Cancel", new DialogInterface.OnClickListener()  
        { 
        public void onClick(DialogInterface dialog, int which)  
        { 
            new AlertDialog.Builder(TUIActivity.this)
            .setMessage("Sure?")
            .setPositiveButton("Yes", 
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            // cancel the download
                        }
                    }
            )
            .setNegativeButton("No", new EmptyListener())
            .show();

        } 
    }); 
    return progressDialog;
}

1 个答案:

答案 0 :(得分:0)

最简单的解决方案:不要使用ProgressDialog。使用标题栏中的进度指示器,或ProgressBar或您正在工作的其他指示器。