I’m a beginner in learning Android, please help me with this.
I keep getting this error:
02-19 16:55:00.330: E/AndroidRuntime(2335):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.mkyong.android/com.mkyong.android.WebViewActivity}:
java.lang.NullPointerException
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
WebView mywebview = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
WebSettings webSettings = mywebview.getSettings();
mywebview.loadUrl("http://www.google.com");
}
my xml file:
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
I think it’s this line
You never say what webView is. You declare mywebview, but not webView