4

We use

InputMethodManager imPharamcy = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imPharamcy .toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);

to get the keyboard forcefully. But the keyboard is not numbers only keyboard. How do i get numbers only keyboard using inputMethod Manager.

In xml i have already given

   android:inputType="phone"
   android:imeOptions="actionNext"              

the editText takes numbers only Strangely in the emulator a number only keypad comes up but on a phone numbers and special charaters keypad comes

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
Ciff
  • 596
  • 3
  • 8
  • 22

1 Answers1

3

See below code:

    // TYPE_CLASS_NUMBER: Class for numeric text. This displays the numbers/symbols keyboard.
editText.setInputType(InputType.TYPE_CLASS_NUMBER);

// TYPE_CLASS_PHONE: Class for a phone number. This displays the phone number keypad.
editText.setInputType(InputType.TYPE_CLASS_PHONE);

Hope you got the point.

Shreyash Mahajan
  • 23,386
  • 35
  • 116
  • 188
  • 3
    That wasn't the question. The question was how to get numbers only keyboard using `InputMethodManager` class, not the `TextView`. I need this for a Cordova app, where the WebView prevents keyboard from showing on focus and I need to force it to show using a plugin. Since it's a WebView and now a textbox, I need to use the `InputMethodManager` only, there are no TextViews to play with. – Mr. TA Jun 01 '16 at 22:32