Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText, show both comma and dot as possible separator in case of numberDecimal input type

Tags:

android

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?

like image 546
XZen Avatar asked Apr 18 '14 13:04

XZen


1 Answers

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.

like image 181
scottt Avatar answered Sep 30 '22 14:09

scottt