Android webview中的软键盘-否“;“下一步”;用于在输入字段之间进行制表的按钮

Android webview中的软键盘-否“;“下一步”;用于在输入字段之间进行制表的按钮,android,webview,Android,Webview,当我聚焦webview输入字段时,我的软键板不显示此按钮。没有找到任何有关启用此功能的特殊设置的信息-我是否遗漏了什么?它不会出现在任何类型的输入字段中(字母/数字) Android版本4.0.3 提前谢谢 不幸的是,这就是它在安卓

当我聚焦webview输入字段时,我的软键板不显示此按钮。没有找到任何有关启用此功能的特殊设置的信息-我是否遗漏了什么?它不会出现在任何类型的输入字段中(字母/数字)

Android版本4.0.3


提前谢谢

不幸的是,这就是它在安卓<4.1中的实现方式

当webkit呈现输入字段时,它会将它们转换为
android.webkit.WebTextView
对象,这些对象决定了软键盘的外观以及4.1以下的外观。我认为没有办法改变这一点或覆盖WebTextView类设置的ImeOptions

这就是为什么如果你有一个纯数字字段,你会看到下一步按钮,但对于其他字段,你会看到“去”按钮。所以我希望看到它,很惊讶你没有

<input type="text" name="..." .... /> ----> on the keyboard you see "Go"
<input type="number" name="..." .... /> ----> on the keyboard you see "Next"
所以很明显,数字和电话字段是下一个。现在我说以下是帮助我使用自定义WebView和覆盖onCreateInputConnection()中的EditInfo的内容(Nexus 4和Nexus 5与Android 4.4.*):


@布伦德尔我这么说,在网络视图中,html无法控制键盘的选项。这是否包括
nextFocusDown
等?(不包括黑客)。我并不知道,除了我在这里回答的问题之外,我还没有深入研究过它,但对于Android,一如既往,我肯定有一种方法:)
case WebTextView.NORMAL_TEXT_FIELD:
                    break;
                case WebTextView.TEXT_AREA:
                    inputType |= InputType.TYPE_TEXT_FLAG_MULTI_LINE
                            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
                            | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
                    action = EditorInfo.IME_ACTION_NONE;
                    break;
                case WebTextView.PASSWORD:
                    inputType |= EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD;
                    break;
                case WebTextView.SEARCH:
                    action = EditorInfo.IME_ACTION_SEARCH;
                    break;
                case WebTextView.EMAIL:
                    // inputType needs to be overwritten because of the different text variation.
                    inputType = InputType.TYPE_CLASS_TEXT
                            | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
                    break;
                case WebTextView.NUMBER:
                    // inputType needs to be overwritten because of the different class.
                    inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL
                            | InputType.TYPE_NUMBER_FLAG_SIGNED | InputType.TYPE_NUMBER_FLAG_DECIMAL;
                    // Number and telephone do not have both a Tab key and an
                    // action, so set the action to NEXT
                    break;
private static class CustomWebView extends WebView {

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

    @Override
    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
        InputConnection inputConnection = super.onCreateInputConnection(outAttrs);
        if (outAttrs != null) {
            // remove other IME_ACTION_*
            outAttrs.imeOptions &= ~EditorInfo.IME_ACTION_GO;
            outAttrs.imeOptions &= ~EditorInfo.IME_ACTION_SEARCH;
            outAttrs.imeOptions &= ~EditorInfo.IME_ACTION_SEND;
            outAttrs.imeOptions &= ~EditorInfo.IME_ACTION_DONE;
            outAttrs.imeOptions &= ~EditorInfo.IME_ACTION_NONE;
            // add IME_ACTION_NEXT instead
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
        }
        return inputConnection;
    }
}