zoukankan      html  css  js  c++  java
  • Android 设置软键盘搜索键以及监听搜索键点击事件

    如图所示,有时候为了布局美观,在搜索时没有搜索按钮,而是调用软件盘上的按钮。调用的实现只需要在XML在输入框中加入android:imeOptions="actionSearch",另外,还要设置android:singleLine="true",保证点击不会换行,最后调用软键盘时,回车键就会显示搜索二字。

    然后调用 OnEditorActionListener,不是OnKeyListener

        searchPatient.setOnEditorActionListener(new TextView.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                        String search = searchPatient.getText().toString().trim();
                        initCaseControl(search);
                        return true;
                    }
                    return false;
                }
            });
  • 相关阅读:
    SQL server 数据库基础语句
    数据库学习的第一天
    C# 函数
    C# for循环的嵌套 作用域
    C# for循环语句
    Docker的基本使用
    django连接postgresql
    docker的安装
    Postgresql的使用
    Celery的介绍
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/9436029.html
Copyright © 2011-2022 走看看