检测键盘搜索按钮 [英] detect keyboard search button

查看:88
本文介绍了检测键盘搜索按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变Android的软键盘显示搜索图标,而不是输入图标。我的问题是:我怎么可以检测该搜索按钮,用户点击

I change android soft keyboard to show search icon rather than Enter icon. My question is: how i can detect that user click on that search button?

推荐答案

在EditText上你可能会用你的输入法的选项进行搜索。

In the edittext you might have used your input method options to search.

<EditText
      android:imeOptions="actionSearch"
      android:inputType="text"/>

现在使用上的EditText编辑器监听器来处理搜索事件,如下所示:

Now use the Editor listener on the EditText to handle the search event as shown below:

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
           // Your piece of code on keyboard search click 
            return true;
        }
        return false;
    }
});

这篇关于检测键盘搜索按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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