Edit: I have looked at the error page for this; no answers work. It seems it is an Android
system bug that has not yet been solved.
First off I've referred to this similar question. But the solution to that question does not seem to be the solution to mine. I have a DialogFragment
that contains only a WebView
. Everything in the WebView
seems to be touchable. However, the problem is that when I touch a form field, the cursor appears but the soft keyboard never shows up!
Here's my code in the onCreateDialog()
method within the DialogFragment
class:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
WebView web = new WebView(getActivity());
web.loadUrl(InternetDialog.this.url);
web.setFocusable(true);
web.setFocusableInTouchMode(true);
web.requestFocus(View.FOCUS_DOWN);
web.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;
}
});
builder.setView(web);
return builder.create();
How can I get the soft keyboard to show up when I select a form field?