webview导致应用崩溃

时间:2015-01-20 04:47:31

标签: java android

我正在为Overclock.net开发应用程序,我有一个webview问题。该类导致应用程序停止。这是我的代码

 package nathan.ocnuo.util;

  import android.app.Activity;
  import android.os.Bundle;
  import android.webkit.WebView;
  import nathan.ocnuo.R;


public class web extends Activity {

private WebView mWebView;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test);
    WebView myWebView = (WebView) findViewById(R.id.webview);

    myWebView.loadUrl("http://www.overclock.net/t/1019761/overclock-net-app/30");
}

text.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="schemas.android.com/apk/res/android";  
 android:orientation="vertical"
 android:layout_width="match_parent"
 android:layout_height="match_parent">

  <WebView xmlns:android="schemas.android.com/apk/res/android"; 
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
 </LinearLayout>

logcat的

 01-19 22:07:57.378 32438-32438/nathan.ocnuo E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: nathan.ocnuo, PID: 32438 ava.lang.IllegalStateException: Could not execute method of the activity at
android.view.View$1.onClick(View.java:3851) at android.view.View.performClick(View.java:4466) at android.view.View$PerformClick.run(View.java:18552) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136)
我非常困惑。任何帮助表示赞赏:)抱歉,如果这篇文章很烦人......

1 个答案:

答案 0 :(得分:1)

确保您在清单文件中添加了Internet权限,如下所示:

 <uses-permission android:name="android.permission.INTERNET" />