Android: Cannot input any digit in EditText field after leading minus sign

51 Views Asked by At

I have an EditText field whose input type is as follows:

android:inputType="numberDecimal|numberSigned"

But after I type minus as the first character (leading minus sign) and then I try to input digit 2 but it is not taking it. In fact, after leading minus, it is not taking any input (no digits, nothing).

The other fields of EditText xml is below:

android:id="@+id/etAmount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/editText"
android:longClickable="false"
android:inputType="numberDecimal|numberSigned"
android:layout_marginTop="20dp"

Please let me know if there is a solution.

2

There are 2 best solutions below

2
Hascher On

You can define a digits property for your editText and you can set the digits that you want to type only. This will help you.

android:digits="0123456789-"
0
AudioBubble On

The problem got solved. There was an input filter in the code that was creating the problem.