actionNone : 回車(chē)鍵叠赦,按下后光標(biāo)到下一行
actionGo : Go窥妇,
actionSearch : 放大鏡
actionSend : Send
actionNext : Next
actionDone : Done标沪,確定/完成巍佑,隱藏軟鍵盤(pán)诫隅,即使不是最后一個(gè)文本輸入框
android:singleline="true"
android:imeoptions="actionSearch"
EditText.setOnEditorActionListener設(shè)置監(jiān)聽(tīng)
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean isOK = true;
switch (actionId) {
case EditorInfo.IME_ACTION_NONE:
Toast.makeText(mContext, "點(diǎn)擊-->NONE", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_GO:
Toast.makeText(mContext, "點(diǎn)擊-->GO", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_SEARCH:
Toast.makeText(mContext, "點(diǎn)擊-->SEARCH", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_SEND:
Toast.makeText(mContext, "點(diǎn)擊-->SEND", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_NEXT:
Toast.makeText(mContext, "點(diǎn)擊-->NEXT", Toast.LENGTH_SHORT).show();
break;
default:
isOK = false;
break;
}