S
S
Sergey2017-10-16 20:45:35
Android
Sergey, 2017-10-16 20:45:35

How to switch keyboard mode from text to telephone (numbers only)?

How to switch keyboard mode from text to phone (numbers only) for only one activity?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-10-17
@sergei_kot

Something doesn’t work for me (the text keyboard pops up when you enter in the input webview field. The inputtype (html) attribute cannot be changed from text to number. Dear experts, how to do what would happen when entering in < .input inputtype="text"> (page loaded in webview) did you open the numeric keypad TYPE_CLASS_PHONE?

public class CustomWebView extends WebView {


    public CustomWebView(Context context) {
        super(context);
    }



    @Override
    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
        InputConnection inputConnection = super.onCreateInputConnection(outAttrs);
        outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
        return inputConnection;
    }


    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        Activity activity = new Activity();
        View  vwf = activity.getCurrentFocus();
        InputMethodManager inputManager =  (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.restartInput(vwf);
        setFocusable(true);
    }


}//class

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question