Android 自定义Action Button

来源:互联网 发布:昌吉有4g网络吗 编辑:程序博客网 时间:2024/06/04 08:15
效果
自定义Action Button - gitonway - Android Dev_ Weekly
 代码
通常我们使用系统的默认方法

<EditText    android:id="@+id/password"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:imeOptions="actionDone"    android:inputType="textPassword" />


有时可能需要自定义action button 的文字,如下

<EditText    android:id="@+id/password"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:imeActionId="@+id/action_sign_in"    android:imeActionLabel="@string/sign_in_short"    android:inputType="textPassword" />

在代码中调用

mEditText = (EditText) view.findViewById(R.id.password);mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {   @Override    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {        if (actionId == R.id.action_sign_in) {            // Do sign in            return true;        }        return false;    }});



0 0
原创粉丝点击