Home  >  Article  >  Java  >  Reasons and solutions why Android WebView cannot pop up the soft keyboard

Reasons and solutions why Android WebView cannot pop up the soft keyboard

高洛峰
高洛峰Original
2017-01-07 11:44:192519browse

requestFoucs(); is invalid.

requestFoucsFromTouch(); is invalid.

webview.setTouchListener; Invalid.

The problem:

When inheriting WebView, pay attention to the construction method:

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 cannot pass 0, the following is the wrong way to write it :

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

The above is the reason why Android WebView cannot pop up the soft keyboard and the solution introduced by the editor. I hope it will be helpful to everyone. If If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!

For more related articles on the reasons and solutions for why Android WebView cannot pop up the soft keyboard, please pay attention to the PHP Chinese website!



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn