4

I want to show android soft keyboard on page load and programmatically focusing a input field.

$('#field').focus();

As far as I researched , this cannot be done other than user generated events , like click event.

So I tried a workaround to focus the input field , and show android keyboard manually by using this code.

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.toggleSoftInputFromWindow(myWebView.getWindowToken() , InputMethodManager.SHOW_IMPLICIT , 0);

Keyboard is successfully showing and input field is also getting focus. But the problem is , it is only showing the standard keyboard. I want to show the keyboard according to the input type specified.

Like if input field is:

<input type="number" id="field" name="field"/> 

Above workaround is showing standard text keyboard , but I want to show a numeric keyboard according to the type in input field.

1
  • did u find the solution..??? Commented Mar 3, 2016 at 9:51

2 Answers 2

1

i've searched a long time before i found solution.

Add this :

imm.restartInput(view); 

after showSoftInput.

This will "recalculate" the kind of keyboard to show regarding focused input

Sign up to request clarification or add additional context in comments.

Comments

-1

Try this:

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

1 Comment

This will show or hide the soft keyboard, but OP is asking how to change the layout from alpha to numeric.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.