gab*_*ldi 4 javascript java android input webview
在某些设备(主要是三星,但也有其他设备)和以下设备的组合上:Android 版本、WebView 版本(即使是 Android 7 中的常青 WebView)和键盘,存在许多问题:
keypress 没有被解雇keydown并且keyup总是包含keyCode=229keypress并被input解雇但不包含密钥textInput 没有被解雇maxlengthinput[type=text]用户键入时不支持属性(maxlength允许超过字符,并且仅在提交表单时验证输入)有没有办法解决这些问题?
我发现如果你扩展WebView和覆盖onCreateInputConnection,所有这些问题都得到了解决:
public class WebViewExtended extends WebView {
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
// This line fixes some issues but introduces others, YMMV.
// super.onCreateInputConnection(outAttrs);
return new BaseInputConnection(this, false);
}
}
Run Code Online (Sandbox Code Playgroud)
覆盖之前onCreateInputConnection:
覆盖onCreateInputConnection(g被按下)后: