android edittext inputType imeOptions 学习

来源:互联网 发布:淘宝商品被投诉假货 编辑:程序博客网 时间:2024/05/16 10:28
<EditText        android:id="@+id/et1"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:bufferType="editable"        android:focusable="true"        android:focusableInTouchMode="true"        android:imeActionLabel="fdfdfd"        android:imeOptions="actionSend"        android:singleLine="true"        android:textStyle="bold|italic"        android:typeface="normal" />    <EditText        android:id="@+id/et2"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:bufferType="editable"        android:focusable="true"        android:inputType="number"        android:focusableInTouchMode="true"        android:imeActionLabel="fdfdfd"        android:imeOptions="actionSearch"        android:singleLine="true"        android:textStyle="bold|italic"        android:typeface="normal" />

inputType="number"
android:imeOptions="actionSearch"
输入法右下角显示的是搜索
android:imeOptions="actionSend"
输入法右下角显示的是发送

调用输入法时 会直接跳到数字界面,且只能输入数字


点击输入法 会触发 以下方法

et1.setOnEditorActionListener(new TextView.OnEditorActionListener() {@Overridepublic boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) {          System.out.println("searech");            return true;        }        return false;}});