怎么设置软键盘中Enter的监听
来源:互联网 发布:windows日语输入法 编辑:程序博客网 时间:2024/05/11 05:00
/**布局中必须设置属性<singleLine & imeOptions>*/<EditText android:id="@+id/edt_searchMicroFilm" android:layout_width="fill_parent" android:layout_height="32dp" android:layout_marginRight="10dp" android:background="@drawable/search_frame_shape_circle" android:gravity="center_vertical" android:hint="@string/plaseInputKeyWords" android:paddingLeft="25dp" android:textColorHighlight="@color/jxInputFrameHintTextColor" android:textColor="@color/jxTitleTextWord" android:imeOptions="actionSearch" android:singleLine="true" android:textSize="14sp" > </EditText>
/**在Activity类中编写自己的功能代码,即设置监听事件:*/editText.setOnEditorActionListene( newTextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event){ if (actionId == EditorInfo.IME_ACTION_SEARCH ||(event!=null && event.getKeyCode()== KeyEvent.KEYCODE_ENTER)) { // 在这里编写自己想要实现的功能 ..... return true; } return false;<pre name="code" class="java"> } });
我想你既然来到这里看这篇文章至少是想要了解怎么去重新设置手机弹出的软键盘上Enter功能。使得点击过Enter键之后,响应自己想要实现的功能。而软件盘的界面替换却有这么一个属性android:imeOptions来满足我们的需要,这个属性的可以取的值有normal,actionUnspecified,actionNone,actionGo,actionSearch,actionSend,actionNext,actionDone,例如:当值为actionNext时enter键外观变成一个向下箭头;当值为actionSearch时候Enter键外观变成“搜索”两个字;而值为actionDone时enter键外观则变成了“完成”两个字。
在进行自己自定义的响应的功能设置时候,要注意<下面三条必须的满足>:
1.在XML布局中设置其属性android:imeOptions,如上图;
2.在XML布局中设置其属性android:singleLine="true",保证点击Enter键时,能被正确监听到;
3.在代码中设置监听:editText.setOnEditorActionListene();并完成自己想要实现的功能代码;
0 0
- 怎么设置软键盘中Enter的监听
- 设置软键盘的Enter图标&监听&两次响应的问题
- android软键盘enter键的替换与事件监听
- android软键盘enter键的替换与事件监听
- android 软键盘Enter键图标的设置 android:imeOptions
- android 软键盘Enter键图标的设置
- android editText 软键盘enter键图标的设置
- android 软键盘Enter键图标的设置 android:imeOptions
- android editText 软键盘enter键图标的设置
- android editText 软键盘enter键图标的设置
- android editText 软键盘enter键图标的设置
- android editText 软键盘enter键图标的设置
- 自定义软键盘的Enter键
- Android中软键盘监听
- Android中软键盘监听
- android SoftKeypad 软键盘的问题及自定义软键盘中Enter键和其相应事件
- 监听软键盘的状态
- Android中EditText监听软键盘的事件
- Android SDK Manager更新、下载速度慢
- 20位活跃在Github上的国内技术大牛
- c语言文件操作 fread(),fseek()
- 列出所有表的列属性
- 人脸识别
- 怎么设置软键盘中Enter的监听
- log4j日志配置
- 3ds Max快捷键、操作技巧、基本概念(更新中)
- Windows内核版本变化(Windows 10 Build 9888 内核版本是 10.0)
- android程序完全退出
- 设计模式原则
- MySQL系列:innodb源码分析之mini transaction
- Makefile(四)
- Spring 事务无法回滚