另一个对话框中的对话框出现问题
下载数据时,我显示一个带有取消按钮的进度对话框。如果按下,则会弹出警报对话框以进行验证。如果确定,下载将被取消并且两个对话框都会消失。但如果用户拒绝取消,两个对话框也会消失。这是非常糟糕的,因为它会误导用户假设下载已完成。我想要的是,进度对话框保留在屏幕上,直到下载真正完成。有什么想法吗?
这是我使用的代码:
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;
}
While dowloading data i display a progressdialog with a cancel button. If pressed an alertDialog pops open for verification. If ascertained, the download is cancelled and both dialog disappear. But if the user negates the cancel, ALSO both dialogs diappear. Which is very bad, because it misleads the user into assuming the download is finished. What I want, is that the progressDialog remains on the screen until the download really is finished. Any ideas?
Here is the code I used:
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的解决方案:不要使用
ProgressDialog
。使用标题栏中的进度指示器、ProgressBar
或其他指示您正在工作的指示器。The simplest solution: don't use a
ProgressDialog
. Use the progress indicator in the title bar, or aProgressBar
, or some other indicator that you are doing work.