zoukankan      html  css  js  c++  java
  • 98、EditText 按键盘查询 触发事件

    只需要在XML在输入框中加入Android:imeOptions=”actionSearch”,调用软键盘时,回车键就会显示搜索二字。

    editSearch.setOnEditorActionListener(new editActionListener());
    class editActionListener implements TextView.OnEditorActionListener {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                ((InputMethodManager) editSearch.getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(
                                mActivity.getCurrentFocus().getWindowToken(),
                                InputMethodManager.HIDE_NOT_ALWAYS);
    
                这里可以操作你要的东东。。。。。。。return true;
            }
            return false;
        }
    }

    在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode=”adjustPan”可以防止软键盘会把原来的界面挤上去的问题

  • 相关阅读:
    2019年8月22日 星期四(杂谈)
    文件读写
    log4j
    java 读写 xlsx
    mongodb的增删改查
    mongodb安装与简单配置
    mondb的特性
    mongodb 的简单应用
    linux 学习1
    linux 安装MySql
  • 原文地址:https://www.cnblogs.com/androidsj/p/5598106.html
Copyright © 2011-2022 走看看