My WebView doesn’t show anything. It is just empty.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<!-- <LinearLayout
android:id="@+id/tableRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/buttonAccept"
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/button_accept" />
<Button
android:id="@+id/buttonDeny"
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/button_deny" />
</LinearLayout> -->
</LinearLayout>
This is the Activity:
public class TermsOfUseDialogActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.terms_menu_dialog);
WebView webview = (WebView) findViewById(R.id.webview);
// WebView webview = new WebView(this);
// setContentView(webview);
String htmlCode = "<html><body>WebView Test<br /><br />New Line Test</body></html>";
// webview.loadDataWithBaseURL(null, htmlCode, "text/html", "UTF-8", null);
// webview.clearView();
webview.loadData(htmlCode, "text/html", "UTF-8");
// webview.reload();
// webview.loadUrl("http://www.google.at");
}
}
As you can see I commented some code out. None if these tries worked except this part…
WebView webview = new WebView(this);
setContentView(webview);
In this case, I see the content but I can’t use this, because I need to use buttons shown in the XML above, too. Any ideas why this doesn’t show any content?
(Internet permissions are set in AndroidManifest)
I found the solution. The layout was incorrect. With the following layout, I’ve got a full screen web view with 2 buttons below: