攻丝的WebView表单字段不显示软键盘 [英] Tapping form field in WebView does not show soft keyboard

查看:148
本文介绍了攻丝的WebView表单字段不显示软键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了自己的WebView,并设置WebChromeClient和WebViewClient对象。当我开始这样的WebView的HTML表单域反应过来的时候我接触他们(光标出现),但他们没有获选,也没有软键盘启动。如果我使用轨迹球选择的形式和preSS它,键盘不会出现。

I created my own WebView and set the WebChromeClient and WebViewClient objects. When I start this WebView, the HTML form fields react when I touch them (a cursor appears), but they do not get selected, nor does the soft keyboard start. If I use the trackball to choose the form and press it, the keyboard does appear.

我试着打电话 myWebview.requestFocusFromTouch()的<一个href="http://stackoverflow.com/questions/3098186/android-how-to-add-custom-soft-keyboard-when-form-field-is-selected-in-webview">this回答建议,但它返回false,并没有帮助。

I tried to call myWebview.requestFocusFromTouch() as this answer suggested, but it returns false and doesn't help.

推荐答案

<一个href="http://$c$c.google.com/p/android/issues/detail?id=7189">http://$c$c.google.com/p/android/issues/detail?id=7189

下面是在其他情况下的修补程序不明确。

Here is a fix in case other were not clear.

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

这篇关于攻丝的WebView表单字段不显示软键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆