Webview html input form not showing/allowing keyboard

11,403

Solution 1

As Brent suggested, following line will serve the purpose -

webView.requestFocus(View.FOCUS_DOWN);

this happens because on page loading webpage loses its focus so this line just bring the focus back to page.

For those who end up at this question, A detailed discussion on this topic is here

Solution 2

None of these worked for me. But applying all-app webViewStyle to the webview fixed everything.

The issue was fixed using style="?android:attr/webViewStyle" in the webview definition, like this:

<?xml version="1.0" encoding="utf-8"?>
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/webViewStyle"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>

Solution 3

I solved this issue myself with further googling I have my webview declared as

WebView wb;

When I launch my webview (in my case a button click) you'll pass the requestFocus statement...

public void onMyButtonClick01(View view)  
{  
    Toast.makeText(this, "Haha!", Toast.LENGTH_SHORT).show(); 
    wb = new WebView(this);
    wb.loadUrl("http://www.test.html");
    setContentView(wb);  
    wb.requestFocus(View.FOCUS_DOWN);
}       
Share:
11,403
Brent Hacker
Author by

Brent Hacker

About a year ago I got the chance to start working as a programmer for the company I work for, since then I've created 3 Android apps, an iPhone app, and many windows programs written in vb.net.

Updated on June 09, 2022

Comments

  • Brent Hacker
    Brent Hacker almost 2 years

    I need some help with showing/allowing the keyboard to show and input.

    My basic app has a main screen with buttons, on button click it opens a webview, one of my buttons opens a webview to an HTML page with an input form. When you click on an input field, the keyboard does not show and when you use the hardware keyboard on the emulator it just brings up chinese suggestions and does not input any text.