1

I have a DialogFragment which has two EditText views. One takes email and another takes phone number of a friend. These two may be filled with a contact from contacts (I have a button that takes to contact picker). I am able to show the keyboard right after launching the fragment with this when focus is on email view by default :

InputMethodManager inputMethodManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

I want to launch soft keyboard with digits 0 - 9 programatically (same like when we touch edittext of phone inputType). What I did is that when user pick contact, it fills the email (contact has only email, say) then I have set focus to phone view using requestFocus() which worked and I see the cursor is moved to phone view. Then I called the above code to show but that did not work. I could find any other way on net too.

Any clue ?

cgr
  • 4,578
  • 2
  • 28
  • 52

1 Answers1

2

I suppose that your keyboard appears upon an EditText. So, the only thing that you have to do to trigger arithmetic keyboard is to declare in your EditText the InputType as number.

<EditText android:inputType="number"/>

and the InputManager stays as you have declared it.

karvoynistas
  • 1,295
  • 1
  • 14
  • 30
  • Will this have the plus symbol add well to be able to enter the complete phone number? Not at my system to quick test. – cgr Nov 26 '15 at 17:08
  • Also how you make it 'upon editext'? Using requestFocus () ? That didn't launch the phoneType keyboard. That's what I mentioned clearly. – cgr Nov 26 '15 at 17:11