Android监听软键盘的方式
16lz
2021-01-23
actionNone : 回车键,按下后光标到下一行
actionGo : Go,
actionSearch : 放大镜
actionSend : Send
actionNext : Next
actionDone : Done,确定/完成,隐藏软键盘,即使不是最后一个文本输入框
在xml中设置属性(此处设置为软键盘显示的内容):
android:imeOptions="actionDone"
android:singleLine="true"
设置监听:
EditText.setOnEditorActionListener设置监听
publicbooleanonEditorAction(TextView v,int actionId, KeyEvent event) {
booleanisOK =true;
switch(actionId) {
case EditorInfo.IME_ACTION_NONE:
break;
case EditorInfo.IME_ACTION_GO:
break;
case EditorInfo.IME_ACTION_SEARCH:
break;
case EditorInfo.IME_ACTION_SEND:
break;
case EditorInfo.IME_ACTION_NEXT:
break;
case EditorInfo.IME_ACTION_DONE:
break;
default:
isOK=false;
break;
}
更多相关文章
- Android软键盘弹出时把布局顶上去,控件乱套解决方法
- android中点击空白处隐藏软键盘
- Android 说说亮屏锁和键盘锁
- android 软键盘 返回键 消失事件 监听
- android 软键盘隐藏 activity初始化时edittext聚焦
- Android 虚拟键盘弹出把底部view顶上去的解决办法
- Android空白处隐藏软键盘方案
- android键盘挡住界面