输入框edittext,改变键盘enter文字

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;

}

});

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容