Tapping form field in WebView does not show soft keyboard
Agreed 10% with Dv_MH's answer. However, the attached class was a little excessive. All I needed to do was extend WebView & return true for onCheckIsTextEditor()
import android.content.Context;
import android.util.AttributeSet;
import android.webkit.WebView;
public class LiveWebView extends WebView {
public LiveWebView(Context context) {
super(context);
}
public LiveWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public LiveWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onCheckIsTextEditor() {
return true;
}
}
From there, I was able to use it as a normal WebView (even in Dialogs).
Alternatively, with less code:
WebView web = new WebView(context) {
@Override
public boolean onCheckIsTextEditor() {
return true;
}
};
http://code.google.com/p/android/issues/detail?id=7189
Here is a fix in case other were not clear.
webview.requestFocus(View.FOCUS_DOWN);
webview.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_UP:
if (!v.hasFocus()) {
v.requestFocus();
}
break;
}
return false;
}
});