WebView textarea doesn't pop up the keyboard

前端 未结 11 1986
野趣味
野趣味 2020-11-28 06:06

When I display a WebView, I don\'t see the soft keyboard popping up. The hard keyboard also doesn\'t work!

What are the usual shortcomings.

The

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 06:35

    The full solution is a bit more than what Sana had. It is documented as a bug over at the Android site ( http://code.google.com/p/android/issues/detail?id=7189 ):

    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;
        }
    });
    

提交回复
热议问题