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;
}
网友评论