Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comma doesnt work on Samsung Android Keyboard

I set InputType.TYPE_NUMBER_FLAG_DECIMAL or InputType.TYPE_CLASS_NUMBER to my EditText and i want to use comma for decimal separator. So i set digits "0123456789.," to EditText.

editText.keyListener = DigitsKeyListener.getInstance("0123456789.,")

I set a TextWatcher on EditText to handle user input. When i clicked comma(",") on Android emulator keyboard, it is working as expected but if i get build on my phone, which has Samsung Keyboard, comma key is disabled and doesnt work. I searched so much but i couldn't find a way.

Any idea with this problem?

enter image description here

like image 940
Darkhmar Avatar asked Dec 20 '25 08:12

Darkhmar


1 Answers

I solved in this way

override fun afterTextChanged(editable: Editable) {
// If the user input from keyboard some special characters like dot, we replace it programmatically with comma
if (editable.toString().contains(".")) {
    editable.delete(editable.toString().length - 1, editable.toString().length)
    editable.insert(editable.toString().length, ",")
    return
} }
like image 72
Marco Avatar answered Dec 22 '25 00:12

Marco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!