prevent ProgressDialog从当我点击搜索按钮被解雇(安卓) [英] Prevent ProgressDialog from being dismissed when I click the search button (Android)

查看:98
本文介绍了prevent ProgressDialog从当我点击搜索按钮被解雇(安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个长时间运行的操作,我展示一个弹出式对话框(从 ProgressDialog 创建prevent等操作的发生)。

In a long-running operation, I'm showing a popup dialog (created from ProgressDialog to prevent other operations from happening).

我已不可撤销与 setCancelable(假),因此,使用后退按钮,我不能将其关闭,但出人意料的是,搜索硬件按钮驳回对话框!

I have made it non-cancellable with setCancelable(false), so I can't close it using the back button, but surprisingly, the Search hardware button dismisses the dialog!

更确切地说,全局搜索应用程序显示,当我回到我的应用程序,该对话框已被驳回。

More exactly, the global search application is displayed, and when I come back to my app, the dialog has been dismissed.

不知道如何prevent对话框被解雇?

Any idea how to prevent the dialog from being dismissed?

推荐答案

这工作(请注意,我把它放在对话框生成器):

This works (notice I put it on the dialog builder):

.setOnKeyListener(new DialogInterface.OnKeyListener() {

    @Override
    public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
            return true; // Pretend we processed it
        }
        return false; // Any other keys are still processed as normal
    }
})

也许它甚至有可能抓住正面和负面的按钮presses和的只有的处理这些,返回true任何其他键。会好奇,如果你能明白这一点......

Maybe it's even possible to grab the positive and negative button presses, and only handle these, return true for any other keys. Would be curious if you can figure that out...

PS:我读的地方有在对话框中更多的漏洞,即你可以摆脱它没有击中上的任何按键。这是显然的。有谁知道任何其他人吗?

PS: I read somewhere there are more "holes" in the dialog, i.e you can get rid of it without hitting any buttons on it. This was apparently one. Does anybody know of any others?

这篇关于prevent ProgressDialog从当我点击搜索按钮被解雇(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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