Z
Z
z0rgoyok2015-08-11 23:43:22
Android
z0rgoyok, 2015-08-11 23:43:22

How to show the software keyboard in WebView if the element is selected by hardware or joystick/remote?

The problem is this:
the application works on a set-top box for a TV, there is an activity with WebView, there is one text field and a button on the page, navigation is carried out by the remote control - an analogue of the keyboard arrows, now when the text field is selected with these arrows, you need to show the keyboard. This does not happen automatically, but the built-in browser can do this. How can you do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Gamega, 2015-08-12
@gadfi

try like this

webview.requestFocus(View.FOCUS_DOWN);
    webview.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                case MotionEvent.ACTION_UP:
                    if (!v.hasFocus()) {
                        v.requestFocus();
                    }
                    break;
            }
            return false;
        }
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question