blueware
blueware

Reputation: 5371

android edittext inputType:textpassword not working with intputType:actionDone on some devices

I am not new to the use of EditText's inputType but now I am having issue when setting android:inputType="textPassword" beside using android:imeOptions="actionDone"

Device used is: LG G4 Android v6.0

Here is my code:

<android.support.design.widget.TextInputLayout
                android:id="@+id/input_layout_password"
                style="@style/TextInputLayoutLoginTheme"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/default_padding_2"
                app:passwordToggleDrawable="@drawable/ic_password_visibility_18dp_selector"
                app:passwordToggleTint="@color/white">

                <com.cashu.app.ui.widgets.CustomEditText
                    android:id="@+id/et_activity_login_password"
                    style="@style/EditTextPasswordTheme"
                    android:layout_width="@dimen/edittext_width"
                    android:layout_height="wrap_content"
                    android:ems="12"
                    android:gravity="center_vertical"
                    android:hint="@string/activity_consumer_login_password_hint"
                    android:imeOptions="actionDone"
                    android:inputType="textPassword"
                    android:maxLines="1"
                    android:textColor="@color/white"
                    android:textSize="@dimen/font_size_small" />

</android.support.design.widget.TextInputLayout>

My code for this EidtText:

mEtPassword.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((actionId & EditorInfo.IME_MASK_ACTION) > 0 || actionId == EditorInfo.IME_NULL) {
                login();
                return true;
            }
            return false;
        }
    });

mEtPassword.addTextChangedListener(new LoginTextWatcher(mEtPassword));

This is not working on my LG G4's device as well the onEditorAction method is not either called !

I tried so many searches and uses other people solutions but it seems a manufacturer issue !

Upvotes: 3

Views: 2069

Answers (3)

blueware
blueware

Reputation: 5371

Finally, I figured it out.

I added this xml property to my EditText:

android:singleLine="true"

I know its deprecated, but android:maxLines="1" not working although its the replacement for singleLine.

I also removed this:

android:imeOptions="actionDone"

Thank you guys for trying to help me.

Upvotes: 3

Umar Ata
Umar Ata

Reputation: 4258

try this to detect enter key

mEtPassword.setOnKeyListener(new View.OnKeyListener() {
                @Override
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    if (event.getAction() != KeyEvent.ACTION_DOWN)
                        // return false;
                        if (keyCode == KeyEvent.KEYCODE_ENTER) {
                            //your necessary codes...

                        }
                    return false;
                }
            });

Upvotes: 0

Shaoran Ding
Shaoran Ding

Reputation: 7

Try using this method

edittext.setTransformationMethod(PasswordTransformationMethod.getInstance());

Upvotes: -2

Related Questions