Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android imeOptions and auto-pressing Login button

Tags:

android

I have typical login screen. I was able to use imeOptions to allow user "tab" from one field to another and on last field(password) I have actionDone - it just closes soft keyboard. Ideally, I like to click "Login" automatically. Is there anything built-in for that?

like image 588
katit Avatar asked Nov 14 '22 23:11

katit


1 Answers

Add imeOptions to your password EditText and define the action programmatically.

XML:

            <EditText
                android:id="@+id/passordEditText"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:hint="Enter password"
                android:inputType="textPassword"
                android:imeOptions="actionSend"/>

Java:

EditText passwordET= v.findViewById(R.id.passwordEditText);
passwordET.setOnEditorActionListener(new TextView.OnEditorActionListener() {
                    public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
                        boolean mHandled = false;
                        if (actionId == EditorInfo.IME_ACTION_SEND) {
                            onClick(yourLogInMethod);
                            mHandled = true;
                        }
                        return mHandled;
                    }
                });
like image 186
POS Avatar answered Dec 23 '22 04:12

POS