I have set input type to be numberdecimal but also want to populate the editText with a "-" programmatically. I can add the text but then I am unable to edit the text as it doesn't confirm to the number decimal format. Any idea on how I can say inputtype is numberdecimal but a "-" can be allowed?
I was able to achieve this behavior by setting digits
xml attribute as follows:
<EditText
...
android:inputType="number"
android:digits="0123456789-"/>
Setting it up programatically (Set EditText Digits Programmatically):
weightInput.setKeyListener(DigitsKeyListener.getInstance("0123456789-"));
I managed to do that with:
android:inputType="number|numberSigned"
android:digits="0123456789-"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With