2017-07-25 39 views
1

在某些设备(主要是三星,但也有其他设备)和组合:Android版本,WebView版本(甚至是Android 7中的常青WebView)和键盘上,还有一些问题:Android WebView HTML输入按键不会触发

  • keypress,不会触发
  • ​​和keyup总是包含keyCode=229
  • keypressinput被解雇,但不包含关键
  • textInput不会触发
  • 当用户键入
  • maxlength属性不上input[type=text]兑现(超过maxlength字符是允许的,只有当表单提交的输入验证)

是否有办法解决这些问题?

回答

0

我发现,如果你扩展WebView并覆盖onCreateInputConnection,所有这些问题是固定的:

public class WebViewExtended extends WebView { 
    @Override 
    public InputConnection onCreateInputConnection(EditorInfo outAttrs) { 
     return new BaseInputConnection(this, false); 
    } 
} 

前覆盖onCreateInputConnection

before

覆盖onCreateInputConnection后(g按下) :

after