Android 将软键盘Enter变为搜索
来源:互联网 发布:数据魔方为什么下线 编辑:程序博客网 时间:2024/06/10 05:34
主要用到的是EditText的一个内部属性:android:imeOptions , 不同属性值对应的含义如下
1.actionUnspecified 未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED.2.actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE3.actionGo 去往,对应常量EditorInfo.IME_ACTION_GO 4.actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH5.actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND6.actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT7.actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE
如果要显示为搜索的话,你可以下面这么做:
- 在布局中的EditText添加属性:
android:imeOptions="actionSearch"
- 在代码中设置监听事件
//键盘中显示搜索按钮 etKeyWord.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == KeyEvent.KEYCODE_ENTER) { //先隐藏键盘 ((InputMethodManager) etKeyWord.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow( InputTagActivity.this .getCurrentFocus() .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); //实现搜索逻辑 gotoSearch(); return true; } return false; } });
0 0
- Android 将软键盘Enter变为搜索
- Android手机软键盘enter改为搜索
- Android软键盘回车键变为搜索键
- 将软键盘的回车按钮变为搜索按钮
- 将软键盘的回车按钮变为搜索按钮
- Android 更改软键盘Enter键为搜索
- android软键盘enter键
- 软键盘,enter键,换成-搜索
- Android开发-让EditText输入时得软键盘的确认键变为搜索键
- android 软键盘Enter键事件处理
- 自定义Android软键盘enter事件
- 自定义Android软键盘enter键
- 将软键盘变成搜索
- Android 软键盘搜索
- Android 将软键盘的回车按钮改变成搜索按钮
- Android edittext将软键盘的回车改为搜索
- EditText在手机弹出的软键盘中,将回车键变为搜索键和点击搜索键时,执行2次搜索解决
- android 软键盘Enter键图标的设置 android:imeOptions
- linked list summary
- Effictive C++导读
- 动态规划法(一)
- Calling a PL/SQL procedure in ODI
- linux多线程服务端编程读书笔记——第三章
- Android 将软键盘Enter变为搜索
- Dreamoon and Sets_Codeforces
- 网易2017校园招聘笔试题 回文序列
- STL中vector,Map,Set的实现原理
- Androidapk瘦身
- 5. Longest Palindromic Substring
- 自定义view的相关知识
- 78-线程清理函数
- ODI Studio拓扑结构的创建与配置(Oracle)