1.actionUnspecified 未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED.
2.actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE
3.actionGo 去往,对应常量EditorInfo.IME_ACTION_GO
4.actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH
5.actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND
6.actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT
7.actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE
mEditText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
mEditText.setSingleLine();
mEditText.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER ) {
//TODO
}
return false;
}
});
注意:要使这个属性起作用,edittext的属性必须为 singleLine, inputType 为 text