Hi,
I am trying Webview tutorial, but not able to get the output. I get the output using programmatic approach, but with XML layout approach, get error ' prcess com.examples.webview has stopped running unexpectedly" <Force Closure>.
I am using Android 2.2 platform.
Please help. My
java source looks like -
package com.examples.webview;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
public class WebApp extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView wv = (WebView)findViewById(R.id.webview);
//WebView wv = new WebView(this);
setContentView(R.layout.main);
//setContentView(wv);
wv.loadUrl("http://www.google.com");
//WebSettings webSet = wv.getSettings();
//webSet.setJavaScriptEnabled(true);
}
}
main.xml is -
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</WebView>
And manifest file is -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examples.webview"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".WebApp"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>