actionNone : 回车键,按下后光标到下一行
actionGo : Go,
actionSearch : 放大镜
actionSend : Send
actionNext : Next
actionDone : Done,确定/完成,隐藏软键盘,即使不是最后一个文本输入框
android:singleline="true"
android:imeoptions="actionSearch"
EditText.setOnEditorActionListener设置监听
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean isOK = true;
switch (actionId) {
case EditorInfo.IME_ACTION_NONE:
Toast.makeText(mContext, "点击-->NONE", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_GO:
Toast.makeText(mContext, "点击-->GO", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_SEARCH:
Toast.makeText(mContext, "点击-->SEARCH", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_SEND:
Toast.makeText(mContext, "点击-->SEND", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_NEXT:
Toast.makeText(mContext, "点击-->NEXT", Toast.LENGTH_SHORT).show();
break;
default:
isOK = false;
break;
}