Android监听软键盘的方式
16lz
2022-03-09
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之设置ListView数据显示的动画效果
- Android中density如何设置
- Android(安卓)强制设置横屏或竖屏 设置全屏
- Android(安卓)重力感应
- Android之使用RatingBar设置游戏难度并保存
- android源码解析--switch
- Android中使用WebView, WebChromeClient和WebViewClient加载网页
- Android(安卓)监听EditText文本输入 EditText监听事和输入事件