2

I have scenario where I allow only 1 character in edittext. so in onTextChanged I have checked if one letter is input, then I switch the focus to next edittext

<EditText
                android:id="@+id/etpinPassword1"
                style="@style/Edittext_with_weight"
                android:imeOptions="actionNext"
                android:inputType="number"
                android:maxLength="1" />

and here my is textWatcher code:

onTextChanged :- >

if (isValueEntered(charSequence)) {
                    etpinPassword2.requestFocus();
                    etpinPassword2.setEnabled(true);
                    appendPassword(charSequence);
                }

private boolean isValueEntered(CharSequence charSequence) {
        return charSequence.length() > 0;
    }

Everything is working fine, except when I come back to an already filled edittext, onTextChanged is never called. I want to call it again so that I can switch the focus to next edittext if first one is already full.

Gaurav Arora
  • 8,282
  • 21
  • 88
  • 143

1 Answers1

0

The problem is you set the max length to 1, so it will prevent you by entering other character.

Rajan Kali
  • 12,627
  • 3
  • 25
  • 37
  • 1
    How can I do both things, I want to set maxLength as 1 and also want to check if a user is typing after 1 digit is entered – Gaurav Arora Sep 12 '17 at 12:54
  • why would user type another character without removing one ? – Rajan Kali Sep 12 '17 at 13:44
  • 1
    I want to handle it, that if already typed and user is still typing it should move to another edittext. Actually I am making a four digit pin view, where I have four edittext with maxLength as 1 for each edittext. – Gaurav Arora Sep 13 '17 at 07:09