Android webview不工作,请帮助
我尝试使用webview显示网页,但遇到了一个大问题,导致我的应用程序意外停止。我试了很多次,但都显示出同样的错误 错误为“webview应用程序意外停止(process net.webview) 我的Java代码:Android webview不工作,请帮助,android,Android,我尝试使用webview显示网页,但遇到了一个大问题,导致我的应用程序意外停止。我试了很多次,但都显示出同样的错误 错误为“webview应用程序意外停止(process net.webview) 我的Java代码: Code: import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class MyWebView extends Activity { /*
Code:
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class MyWebView extends Activity {
/** Called when the activity is first created. */
WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("http://www.google.com");
}
}
我的XML布局:
Code:
<?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"
/>
代码:
我的清单文件:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.WebView"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".WebView"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
代码:
清单中的活动名称错误。应该是:
<activity android:name=".MyWebView"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
清单中的活动名称错误。应该是:
<activity android:name=".MyWebView"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
非常感谢您。你是我的救星。我为此花了一天时间。祝你假期愉快。不客气。如果它回答了您的问题,请勾选左侧的绿色勾号(我想)来接受这个答案。非常感谢。你是我的救星。我为此花了一天时间。祝你假期愉快。不客气。如果它回答了您的问题,请勾选左侧的绿色勾号(我想)来接受这个答案。