I need to let user choose between two variants when he inputs decimal number:
use comma(,) as separator
use dot(.) as separator
By default if I use inputType="numberDecimal"
in the EditText
xml config - EditText
shows only digits and comma (,
) as possible separator.
I've tried to use android:digits="0123456789
, in my EditText
config, but without result - EditText
widget shows just digits and comma.
I want to have both variants (.
and ,
) available for user on on-screen keyboard when he tries to input decimal number.
Could you please advise?
Specifying both android:inputType="numberDecimal"
and android:digits="0123456789,."
will display a keyboard with mostly just numbers and punctuation (depending on the user's chosen keyboard). It will also limit the characters accepted as input to those in your digits attribute.
If you'd like to further limit the keyboard to display only certain characters, you'll need to define a custom one. Here's one of the better tutorials on doing that.
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