Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is EditText repeating text when entering a not allowed char defined by "android:digits" attribute?

My Activity has an EditText as defined bellow:

<EditText 
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="text"
    android:digits="0123456789.:"
    />

The allowed input should be ., : and numbers. But if a not allowed char is typed when the EditText is empty the text starts to be duplicated.

For example, assuming the EditText is empty, type the following sequence: abc123.

On my device the result is 1112123, but the expected result should be just 123.

As this should be as simple as possible, I would not like to use an InputFilter.

like image 819
tato.rodrigo Avatar asked Aug 25 '14 19:08

tato.rodrigo


1 Answers

In fact this has something to do with the default InputFilter for android:digits (DigitsKeyListener), the android:inputType="text" and the current Keyboard.

The keyboard suggestions can be messy when using android:digits. As I do not need keyboard suggestions for this specific EditText I changed the android:inputType to textNoSuggestions and now it is working as expected.

like image 101
tato.rodrigo Avatar answered Oct 21 '22 04:10

tato.rodrigo