0

在下载数据时,我会显示一个带有取消按钮的进度对话框。如果按下警报对话框,则会弹出以进行验证。如果确定,则取消下载并且两个对话框都消失。但是如果用户否定取消,两个对话框也会消失。这是非常糟糕的,因为它会误导用户假设下载已完成。我想要的是,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;
}
4

1 回答 1

0

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

于 2010-12-26T17:42:54.267 回答