android editText 软键盘enter键图标的设置
软件盘的界面替换只有一个属性android:imeOptions,
EditText通过设置android:imeOptions来改变默认的”文本或者样式。这里举几个常用的常量值:
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
<EditText android:id="@+id/msg_edit" android:layout_width="fill_parent" android:layout_height="32dp" android:layout_centerVertical="true" android:layout_toLeftOf="@id/send_msg" android:background="@drawable/send_voice_bg" android:singleLine="true" android:paddingLeft="8dp" android:imeOptions="actionSend" android:textSize="18sp" />
然后需要重写监听事件,完成想要的功能:
sendMsgEidt.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND) { // TODO } return false; } });