帮我。我试图在 android 中显示我的 html 页面。但它显示错误。
我在xml中的代码,
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical" />
就像在java中一样;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView wv;
wv = (WebView) findViewById(R.id.webview);
wv.loadUrl("file:///android_asset/chapter1.html");
}
}
但是,在运行应用程序时......它显示了很多错误,如下所示;
07-31 11:04:05.056: D/AndroidRuntime(1008): Shutting down VM
07-31 11:04:05.096: W/dalvikvm(1008): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
07-31 11:04:05.136: E/AndroidRuntime(1008): FATAL EXCEPTION: main
07-31 11:04:05.136: E/AndroidRuntime(1008): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thaufeeq.tamilquran/com.thaufeeq.tamilquran.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.os.Handler.dispatchMessage(Handler.java:99)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.os.Looper.loop(Looper.java:137)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-31 11:04:05.136: E/AndroidRuntime(1008): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 11:04:05.136: E/AndroidRuntime(1008): at java.lang.reflect.Method.invoke(Method.java:511)
07-31 11:04:05.136: E/AndroidRuntime(1008): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-31 11:04:05.136: E/AndroidRuntime(1008): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-31 11:04:05.136: E/AndroidRuntime(1008): at dalvik.system.NativeStart.main(Native Method)
07-31 11:04:05.136: E/AndroidRuntime(1008): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
07-31 11:04:05.136: E/AndroidRuntime(1008): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-31 11:04:05.136: E/AndroidRuntime(1008): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.Activity.setContentView(Activity.java:1881)
07-31 11:04:05.136: E/AndroidRuntime(1008): at com.thaufeeq.tamilquran.MainActivity.onCreate(MainActivity.java:13)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.Activity.performCreate(Activity.java:5104)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-31 11:04:05.136: E/AndroidRuntime(1008): ... 11 more
07-31 11:04:05.136: E/AndroidRuntime(1008): Caused by: java.lang.reflect.InvocationTargetException
07-31 11:04:05.136: E/AndroidRuntime(1008): at java.lang.reflect.Constructor.constructNative(Native Method)
07-31 11:04:05.136: E/AndroidRuntime(1008): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
07-31 11:04:05.136: E/AndroidRuntime(1008): ... 23 more
07-31 11:04:05.136: E/AndroidRuntime(1008): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060001 a=-1 r=0x7f060001}
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.content.res.Resources.loadDrawable(Resources.java:1927)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.View.<init>(View.java:3330)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.View.<init>(View.java:3259)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.view.ViewGroup.<init>(ViewGroup.java:425)
07-31 11:04:05.136: E/AndroidRuntime(1008): at android.widget.RelativeLayout.<init>(RelativeLayout.java:210)
07-31 11:04:05.136: E/AndroidRuntime(1008): ... 26 more