8

I want to specify that Android should start the soft keyboard for a given EditText in the numeric/symbols mode. I know this can be done by setting the input type of the EditText to be numeric using EditText.setInputType() except that I do not want to restrict the input type for the EditText to numeric input only**. Is there another way to tell Android what keyboard it should open for a given EditText?

** I want essentially a Math class of numeric input, accepting arbitrary mathematical expressions, including [0,9.+-/*()@:].

Bee
  • 14,277
  • 6
  • 35
  • 49
  • Almost the same question: http://stackoverflow.com/questions/25219855/how-to-show-android-keyboard-with-symbols-mode-by-default – OneWorld Mar 23 '15 at 09:50

2 Answers2

-2

After some research and trying lots of different things, I found the answer:

editField.setRawInputType(InputType.TYPE_CLASS_NUMBER);
//           ^^^ note the Raw!

So you need the Raw version of setting the input type to circumvent a KeyListener being set, which restricts the input.

Philipp F
  • 874
  • 9
  • 29
  • 3
    SetInputType & SetRawInputType restricts input which the question specifically stated they did not want to do – AlanKley Jun 09 '13 at 14:05
-3

I believe the magic is in:

editText.setInputType(InputType.TYPE_CLASS_NUMBER);
user432209
  • 20,007
  • 10
  • 56
  • 75
  • 2
    I'm pretty sure this makes the input accept only digits. I'll verify, though. – Bee Feb 08 '11 at 21:49
  • 1
    SetInputType & SetRawInputType restricts input which the question specifically stated they did not want to do. – AlanKley Jun 09 '13 at 14:06