Reputation: 4636
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 ?
Upvotes: 1
Views: 50
Reputation: 1285
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.
Upvotes: 2