如何避免当用户触摸屏幕驳回我的进度对话框? [英] How to avoid dismissing my progress dialog when the user touches the screen?

查看:138
本文介绍了如何避免当用户触摸屏幕驳回我的进度对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,当用户下载一个文件,该文件显示一个进度对话框的Andr​​oid项目。

I'm working on an android project which displays a progress dialog when the user downloads a file.

但是,当用户触摸屏幕,被驳回的进度对话框,而无需等待的100%。 我已经尝试使用这样的:

But when the user touches the screen, the progress dialog is dismissed without waiting the 100%. I already tried to use this:

 public boolean onTouchEvent(MotionEvent e) {
        return true;
    } 

但它不工作。

But it's not working.

我怎样才能避免这种情况?

How can I avoid this?

更新1:

看来setCancelable(假)工作正常。感谢您对我付出的答案,但是,当下载持久和用户决定放弃这将是不可能的,因为我已经取消了返回键code:

It seems that setCancelable(false) works fine. Thanks you very much for your answers but when the downloading long-lasting and the user decides to abandon it'll be impossible because I already deactivated the back keyCode:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

我如何能算出这个?

How can I figure this out?

推荐答案

使用 dialog.setCancelable(假);

例如:

        ProgressDialog dialog = new ProgressDialog(WiFiFinderActivity.this);
        dialog.setMessage("please wait...");
        dialog.show();
        dialog.setCancelable(false);
        dialog.setCanceledOnTouchOutside(false);

这篇关于如何避免当用户触摸屏幕驳回我的进度对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆