actionUnspecified 未指定,对应常量EditorInfo.IME_ACTION_UNSPECIFIED.
actionNone 没有动作,对应常量EditorInfo.IME_ACTION_NONE
actionGo 去往,对应常量EditorInfo.IME_ACTION_GO
actionSearch 搜索,对应常量EditorInfo.IME_ACTION_SEARCH
actionSend 发送,对应常量EditorInfo.IME_ACTION_SEND
actionNext 下一个,对应常量EditorInfo.IME_ACTION_NEXT
actionDone 完成,对应常量EditorInfo.IME_ACTION_DONE
配合singline=true;可以实现enter箭头改为对应文字。
监听方法:
Edit.setOnEditorActionListener(newTextView.OnEditorActionListener() {
@OverridepublicbooleanonEditorAction(TextView v,intactionId, KeyEventevent){if(actionId == EditorInfo.IME_ACTION_SEARCH (搜索)||(event!=null&&event.getKeyCode()== KeyEvent.KEYCODE_ENTER)){if(TextUtils.isEmpty(mSearchEdit.getText())){
mSearchEdit.requestFocus();
mSearchEdit.setError("不能为空");
}else{//do reseach}returntrue;
}returnfalse;
}
});
网友评论