欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android WebView无法弹出软键盘的原因及解决办法

程序员文章站 2024-03-02 22:51:46
requestfoucs();无效。 requestfoucsfromtouch();无效。 webview.settouchlistener;无效。 问题所...

requestfoucs();无效。

requestfoucsfromtouch();无效。

webview.settouchlistener;无效。

问题所在:

继承webview时,注意构造方法:

public commonwebview(context context) {
super(context);
init();
}
public commonwebview(context context, attributeset attrs) {
super(context, attrs);
init();
}
public commonwebview(context context, attributeset attrs, int defstyleattr) {
super(context, attrs, defstyleattr);
init();
}

defstyleattr不能传0,如下错误写法:

public commonwebview(context context) {
this(context,null,0);
}
public commonwebview(context context, attributeset attrs) {
this(context, attrs,0);
}
public commonwebview(context context, attributeset attrs, int defstyleattr) {
super(context, attrs, defstyleattr);
init();
}

以上所述是小编给大家介绍的android webview无法弹出软键盘的原因及解决办法,希望对大家有所帮助