被解雇的搜索按钮,点击不可取消对话框 [英] Non-cancelable dialog being dismissed on search button click

查看:131
本文介绍了被解雇的搜索按钮,点击不可取消对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我展示我的应用程序中的不可取消,对话,但被取消,如果用户presses搜索按钮。我试着重写onSearchRequested和的onkeydown,但它并不能帮助。任何建议?

I'm showing a non-cancelable dialog in my application, but it gets cancelled if the user presses SEARCH button. I've tried to override onSearchRequested and onKeyDown, but it doesn't help. Any suggestion?

推荐答案

我也遇到了这个问题,并Jamasan的解决方案并没有为我工作。我反而增加了以下code到我的自定义对话框类(扩展对话):

I also came across this problem and Jamasan's solution did not work for me. I instead added the following code to my custom dialog class (extending Dialog):

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

键code和KeyEvent.KEY code_SEARCH都是int类型。该文档为onKeyDown说:

keyCode and KeyEvent.KEYCODE_SEARCH are both int. The docs for onKeyDown says

如果你处理的事件,返回true。   如果你想允许的情况下要   由下一个接收器,处理返回   假的。

If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

我的作品。

这篇关于被解雇的搜索按钮,点击不可取消对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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