1

I have a user reporting an error with my app. I have several EditText fields in my layout. I only want the user to be able to enter signed decimal numbers. However, I don't have the layout declare them to be number|numberSigned|numberDecimal because I have a custom TextWatcher attached to these fields which handles the input and makes sure it is correct. I do this because I want the minus key to act as a toggle.

Let's say, the field has "300" in it. If the user taps minus, my custom TextWatcher intercepts it and turns it into "-300" instead of "300-". If they tap minus again, it'll remove the existing minus and change it to "300".

This works just fine for just about everybody, but it doesn't work on the Kindle Fire. The decimal point and the minus key on the virtual keyboard are disabled, so they don't even have the option of tapping those keys and letting the custom text watcher do its work.

If I do declare the fields to be number|numberSigned|numberDecimal, then the fields won't let the user tap the minus key unless the cursor is in the left most position (i.e. before the 3 in 300).

How can I tell the Kindle Fire to make sure the decimal point and minus keys need to be active, but at the same time not restrict the user's allowed input before it reaches my custom TextWatcher... you know, like the way EVERY other Android device has been working for me? :)

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229
  • There was a way to force the numeric keypad without restricting the EditText to "number". That might work for you since it would allow the Fire to input "300-". I just don't remember how :O) – zapl Apr 17 '12 at 23:30
  • `theEditText.setRawInputType(Configuration.KEYBOARD_12KEY)` May that helps. Disabled `-` sounds really strange. – zapl Apr 17 '12 at 23:40
  • @zapl It turns out that DID help. If you'll post that as an answer, I'll accept it so you can get the rep. – Kenny Wyland May 03 '12 at 18:57
  • You should have a better example now how it works, so you could post what you did as answer - less work for the lazy :) – zapl May 03 '12 at 20:24

1 Answers1

0

The answer from @zapl:

theEditText.setRawInputType(Configuration.KEYBOARD_12KEY)

worked! Go find some other good answer of his and upvote him so that he can get proper credit for this answer. ;)

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229