I am using a view to enter user's four digit PIN. the UI consists of 4 edittext each having maxLength set to 1. On entering value to edit text1, focus is then shifted to the second edittext and so on. each Edittext input type is : numberPassword.
<EditText android:id="@+id/ed_1" android:layout_width="20dp" android:layout_height="20dp" android:gravity="center" android:inputType="numberPassword" android:maxLength="1" /> In java, to shift the focus, we have applied following text watcher to each of the edittext:
ed1.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.toString().length() == 1) { ed1.clearFocus(); ed2.requestFocus(); ed2.setCursorVisible(true); } } @Override public void afterTextChanged(Editable s) { } }); Problem is, value of edittext are not changing to *, it shows the real input number (not changing to password). Only 1st and last are changing to *, where as center two that means edittext 2 and edittext 3 are still have visible passwords.
Right now: We have 4 input Edittexts
desired output should be: | * | * | * | * |
When we fill the values, and switches the focus, by using java code specified, they get change to: (input value: 1234): | * | 2 | 3 | * |
If we focus back on either of the center edit texts, then value changes to password. Is it because of removing focus, and the transformation time required to change a field to password takes more time? Is there any method with which we can forcefully change the value to password.