Android_设置软盘监听事件

来源:互联网 发布:阿里云acp认证 编辑:程序博客网 时间:2024/05/29 19:13

Android软盘一般是伴随着EditText来显示和隐藏,那么对软盘的一些按钮的监听也需要借助于EditText。

软键盘的Enter键默认显示的是“完成”文本,通过设置android:imeOptions来改变默认的“完成”文本。这里举几个常用的常量值:

actionUnspecified  未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED.

actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE

actionGo 去往,对应常量EditorInfo.IME_ACTION_GO

actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH

actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND

actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT

actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE

Enter键事件捕捉代码

一、可以通过setOnEditorActionListener设置事件处理。


editText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);editText.setOnEditorActionListener(newTextView.OnEditorActionListener() {public booleanonEditorAction(TextView v, intactionId,KeyEvent event) {if(actionId == EditorInfo.IME_ACTION_SEARCH|| (event !=null&& event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {//执行搜索功能executeSearchEvent();return true;}return false;}});


原创粉丝点击