android EditText imeOptions属性和各属性setOnEditorActionListener

来源:互联网 发布:建工金源网络培训平台 编辑:程序博客网 时间:2024/06/06 03:37

 点击输入框时,弹出软键盘,细心的会发现软件上面右下角的按钮,有时会有不同:








这样就关系到EditText的属性:imeOptions

设置 android:imeOptions=”actionDone” ,软键盘下方变成“完成;

android:imeOptions=”actionSend” 软键盘下方变成“发送”

android:imeOptions=”actionSearch” 软键盘下方变成“搜索“等属性


edittext.setOnEditorActionListener(this);为edittext这个属性按钮的监听事件


@Overridepublic boolean onEditorAction(TextView v, int actionId, KeyEvent event) {    switch (actionId) {        case EditorInfo.IME_ACTION_SEND://你点了软键盘'发送'按钮"                      break;
case EditorInfo.IME_ACTION_GO://你点了软键盘'去往'按钮"                      break;
case EditorInfo.IME_ACTION_SEARCH://你点了软键盘'搜索'按钮"                      break;
case EditorInfo.IME_ACTION_DONE://你点了软键盘'完成'按钮"                      break;
} return false;}


原创粉丝点击