Android的 - 如何禁用搜索按钮长preSS(的Nexus One) [英] Android - how to disable long press on Search button (Nexus One)

查看:195
本文介绍了Android的 - 如何禁用搜索按钮长preSS(的Nexus One)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android的文档介绍了如何禁用搜索搜索功能活动: 公共布尔onSearchRequested(){     返回false;  }

The Android documentation describes how to disable the search the search feature in Activity: public boolean onSearchRequested() { return false; }

这工作正常的搜索按钮,在Nexus One上很短的preSS。 但是,它不会禁用长preSS,仍然触发了一个语音搜索。

This works fine for a short press of the search button on the Nexus One. However, it doesn't disable the long press, which still fires off a voice search.

我如何禁用长preSS语音搜索?

How do I disable the long press Voice search?

谢谢...

推荐答案

我伸出斯坦的答案,只禁用长preSS事件。

I extended Stan's answer to only disable long press events.

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

    return super.onKeyDown(keyCode, event);
}

这篇关于Android的 - 如何禁用搜索按钮长preSS(的Nexus One)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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