Having a really odd problem when trying to create a web view in an activity.
I was following the Android WebView guide to do this (http://developer.android.com/guide/webapps/webview.html)
My app has a main menu with a button on it that leads to an activity that is supposed to open a web view. It works just fine when I use an Intent, but I need more flexibility so that isn’t really an option.
Here is my webview.xml file:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</WebView>
This is what is in my WebView Activity file:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webview = (WebView) findViewById(R.id.webview);
diningWebView.loadUrl(http://www.google.com);
}
The problem is that my findViewById() is returning null, but I don’t know why.
Any ideas?
You forgot your setContentView()