german decimal point in TextField on android

142 views
Skip to first unread message

Nikolaj Weise

unread,
Apr 7, 2014, 7:08:14 AM4/7/14
to codenameone...@googlegroups.com
Hi,

in Germany this is a decimal point: ,
and this is a grouping symbol: .

When setting a TextField's constraint to DECIMAL my android phone doesn't let me use comma (,) as decimal point. I cannot write it, means nothing happens when clicking on comma.
It works perfectly on iOS and simulator. They both understand to translate a comma (,) into a real decimal point (.).

What do I have to do to tell android to use german decimal settings?

Shai Almog

unread,
Apr 7, 2014, 1:11:15 PM4/7/14
to codenameone...@googlegroups.com
Hi,
we use the native input for both Android and iOS so this maps to the locale functionality of the native platform.
I suggest checking your Android input settings especially if you installed a custom keyboard.

Nikolaj Weise

unread,
Apr 8, 2014, 4:20:49 AM4/8/14
to codenameone...@googlegroups.com
Google says this is a known issue at the Android SDK. I guess you are using it in some way in your build server.

Is it possible to extend TextField/TextArea or VirtualKeyboard to implement a constraint myself? The easiest (and most dirty) way is to check input with a DataChangeListener. Do you recommend another way?

Chen Fishbein

unread,
Apr 8, 2014, 7:50:08 AM4/8/14
to codenameone...@googlegroups.com
Hi,
1)We don't use code from the Android SDK for the Text input we simply invoke the platform text input, is this working for you on a simple android native project?
2)You can add DataChangeListener to validate input

Nikolaj Weise

unread,
Apr 8, 2014, 10:48:40 AM4/8/14
to codenameone...@googlegroups.com
From what I've read it works only with a workaround when using android SDK - I did not try.

The nice thing is, when setting a TextField's constraint to DECIMAL the number keyboard shows up automatically when clicking on the TextField. But I can't use a comma then (on android). When using a DataChangeListener I'm able to validate input but I have to use ANY constraint if I want to validate comma. With ANY the qwertz/qwerty keyboard opens instead of the number keyboard. So the user has to change it manually.
How am I able to say that the number keyboard has to show up with using the ANY constraint?

Shai Almog

unread,
Apr 8, 2014, 2:51:06 PM4/8/14
to codenameone...@googlegroups.com
Do you have a link to the suggested workaround?

Nikolaj Weise

unread,
Apr 9, 2014, 8:03:27 AM4/9/14
to codenameone...@googlegroups.com
This approach looks easy: http://stackoverflow.com/a/16772758
(It doesn't check locale but it's a first step to allow comma.)

Shai Almog

unread,
Apr 9, 2014, 1:19:13 PM4/9/14
to codenameone...@googlegroups.com
That should be pretty simple to add. We'll add it conditionally so it doesn't break other code.
In your init(Object) method do:
Display.getInstance().setProperty("andAddComma", "true");

Then if you define a field as decimal the comma character should appear as well (assuming the stack overflow code is correct).
Reply all
Reply to author
Forward
0 new messages