我正在webview
Android 上尝试一个非常简单的应用程序。虽然程序构建正常,但存在我无法解码的运行时错误。布局:
<?xml version="1.0" encoding="utf-8" ?>
<Webview xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/helloWebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
编码:
/* Program to create sample webview.
* Steps:
* 1. Create webview.
* 2. Show some website in it.
* 3. Show some transitions as well.
*/
package com.sriram.hellowebview;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.webkit.WebView;
public class helloWebview extends Activity {
WebView myWebview;
String url = "http://www.google.com";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello_webview);
Log.v(this.toString(), "Starting activity.");
myWebview = (WebView) findViewById(R.id.helloWebview);
Log.v(this.toString(), "Getting settings.");
//myWebview.getSettings().setJavaScriptEnabled(true);
Log.v(this.toString(), "Loading URL now.");
myWebview.loadUrl(url);
Log.v(this.toString(), "Loaded URL.");
//open all links within the same webview.
//myWebview.setWebViewClient(new WebViewClient());
//Log.v(this.toString(), "All done here.");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_hello_webview, menu);
return true;
}
}
观察到的错误:
03-24 14:48:27.618: E/AndroidRuntime(388): Uncaught handler: thread main exiting due to uncaught exception
03-24 14:48:27.658: E/AndroidRuntime(388): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sriram.hellowebview/com.sriram.hellowebview.helloWebview}: android.view.InflateException: Binary XML file line #3: Error inflating class Webview
我在大型项目中遇到过详细说明 OutOfMemoryExceptions 的类似错误,但由于上述代码是项目的全部内容,因此这似乎不是一个可能的解释。