I have a webview where I manually show the keyboard on the login screen and focus on the input field.
field:
<input type="password" maxlength="4" pattern="[0-9]*" id="pin">
Keyboard focus and display:
webView.requestFocus(View.FOCUS_DOWN); webView.loadUrl("javascript:document.getElementById('pin').focus();"); InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(webView, InputMethodManager.SHOW_IMPLICIT);
The login screen consists of only a PIN code field in which the user enters 4 digits. The problem is that by default it shows a regular alpha keyboard, and I want it to display a numeric keyboard instead. I have seen many examples of using EditText properties to control keyboard type, for example.
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); EditText.setInputType(InputType.TYPE_CLASS_PHONE); [select Input type as according to ur requirement] mgr.showSoftInput(EditText, InputMethodManager.SHOW_IMPLICIT);
But can you tell the keyboard itself what type to show or set the attribute in the WebView?
source share