1] 4-digit input fields without input:

2] 4-digit input field with input:

As the user switches to the 4-digit pin input unit, he turns to a point, if the user wants to delete the last digit by pressing the "Back" button, the user input is deleted with the points converted to the input field again. If the user has the wrong input, he cannot convert the point to the input field, touching it, he must perform the reverse deletion from right to left.
I see a possible solution with custom widgets displaying / viewing view settings based on user input detected using the TextWatcher implementation. But is there an existing EditText widget in the Android platform that has any style configuration with which I can encode in XML to get the aforementioned user interface change?
So far, for manual changes, I made the following changes (The code is for one input field, which was used to create a group of 4 input fields):
XML layout for a single input window:
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <EditText android:id="@+id/pin_edit_box" style="@style/pin_edittext_style" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:digits="0123456789" android:focusable="true" android:imeOptions="actionNext" android:inputType="numberPassword" /> <ImageView android:id="@+id/pin_input_dot" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minEms="3" android:focusable="false" android:layout_centerInParent="true" android:enabled="false" android:src="@drawable/ic_green_dot" android:visibility="gone" /> </RelativeLayout>
Text Change Listener:
pin_edit_box.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { int length = editable.toString().length(); if (length == 1) { pin_edit_box_this.setVisibility(View.INVISIBLE); pin_input_dot_this.setVisibility(View.VISIBLE); pin_edit_box_next.requestFocus(); } else if (length == 0) {
When you try to detect an event to return or remove a button from
boolean onKeyDown (int keyCode, KeyEvent event) { }
An event with the KeyEvent.KEYCODE_DEL keyboard is never detected to make the views visible / invisible after a backward click. Official documentation says that events with a soft keyboard, which cannot always be delivered, will not always work.
As soft input methods can use multiple and ingenious text input methods, there is no guarantee that any keystroke on a soft keyboard will generate a key event: this is at the discretion of IME and the fact of sending such events is not recommended.
More here
Note: the screenshots above are taken from the BHIM application , which is intended for Indian money transactions.