Brent Hacker
Brent Hacker

Reputation: 394

Webview html input form not showing/allowing keyboard

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.

Upvotes: 5

Views: 12205

Answers (3)

Aliya
Aliya

Reputation: 1178

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"/>

Upvotes: 5

Darpan
Darpan

Reputation: 5795

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

Upvotes: 8

Brent Hacker
Brent Hacker

Reputation: 394

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

Upvotes: 3

Related Questions