EditView之IME

讲解一

            <EditText
                android:id="@+id/password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/login_password"
                android:imeActionId="@+id/login"
        android:imeActionLabel="@string/action_login_short"
                android:imeOptions="actionGo"
                android:inputType="textPassword"
                android:maxLines="1"
                android:singleLine="true" />

其中,
imeOptions:设置键盘中回车键的anction

        mPasswordView = (EditText) findViewById(R.id.password);
        mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
                if (id == R.id.login || id == EditorInfo.IME_ACTION_GO) {
                    attemptLogin();//
                    return true;
                }
                return false;
            }
        });

imeActionId:标识此Action的ID,主要用于在代码中动态获取
imeActionLabel:如果屏幕够大,比如横屏的时候,可以在EditText旁边自定义一个按钮,这就需要通过该属性来设置

你可能感兴趣的:(EditView之IME)