1
android:inputType="numberDecimal|numberSigned"

Did not work right, the keyboard that pops up doesn't allow the negative sign.

So I tried using this class from a similar question:

Android InputType layout parameter - how to allow negative decimals?

But again it gives the same keyboard with no negative sign.

I'm trying to compile for android 2.3.x

7
  • 2
    What device / keyboard app are you using? It is up to the keyboard app to respect the intputType that you give it, some keyboards (even some that come preloaded on many phones) are very bad about doing so.
    – FoamyGuy
    Commented Mar 4, 2013 at 4:34
  • It's a default LG keyboard. I'm guessing in order to provide compatibility I should just allow any and all strings, then try to parse double and throw errors as needed?
    – user1438374
    Commented Mar 4, 2013 at 4:36
  • 1
    yeah, you should definitely be doing validation if you need to ensure a double value. Even if inputType worked perfectly it only sets which "mode" the keyboard is shown in, i.e. number/symbol mode, or number pad mode, letter mode etc.. You could try type "phone" that should show the number pad, which I think has a decimal on it. Not sure about a negative sign though. It is important to remember even though you'll be opening up to a certain "mode" the user could still switch to a different one, which is why validation is so important.
    – FoamyGuy
    Commented Mar 4, 2013 at 4:39
  • 1
    try type "phone" if that doesn't work I don't really have much else. You do have the option to create your own input view for this specific Activity if you wish, then you can be sure it will be the same across any device, but it will be much more complex than using the default keyboard the user has chosen.
    – FoamyGuy
    Commented Mar 4, 2013 at 4:46
  • 1
    Nice, glad it works. Be aware there may be some odd devices out there that may not have both a decimal and a negative sign on the number pad, don't be taken by surprise if you get users who come to you with that.
    – FoamyGuy
    Commented Mar 4, 2013 at 14:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.