Ali
Ali

Reputation: 61

Android WebView error

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

Upvotes: 1

Views: 444

Answers (1)

luddite
luddite

Reputation: 430

I think it's this line

webView.getSettings().setJavaScriptEnabled(true);

You never say what webView is. You declare mywebview, but not webView

Upvotes: 3

Related Questions