Kristaps Grinbergs
Kristaps Grinbergs

Reputation: 352

Focus input element and show keyboard in Android WebView on load

I have problem with Android WebView. I want to focus input element and show keyboard on page load without any user actions. Setting input element focus works fine, but keyboard isn't showing. If I make some button in HTML with same action to set focus then keyboard will appear.

Is this even doable to focus input element in WebView and show keyboard on page load?

Thanks!

Upvotes: 4

Views: 3294

Answers (1)

Atetc
Atetc

Reputation: 1693

You must force open the keyboard:

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

You should also make sure that your WebView has focus and field of content is tagged with:

type="number"

Upvotes: 2

Related Questions