启动活动时出现以下异常:
05-28 13:34:09.399: E/AndroidRuntime(502): FATAL EXCEPTION: main
05-28 13:34:09.399: E/AndroidRuntime(502): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nykkos.personalize/com.nykkos.personalize.screens.SummaryCostScreen}: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.os.Handler.dispatchMessage(Handler.java:99)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.os.Looper.loop(Looper.java:137)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-28 13:34:09.399: E/AndroidRuntime(502): at java.lang.reflect.Method.invokeNative(Native Method)
05-28 13:34:09.399: E/AndroidRuntime(502): at java.lang.reflect.Method.invoke(Method.java:511)
05-28 13:34:09.399: E/AndroidRuntime(502): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-28 13:34:09.399: E/AndroidRuntime(502): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-28 13:34:09.399: E/AndroidRuntime(502): at dalvik.system.NativeStart.main(Native Method)
05-28 13:34:09.399: E/AndroidRuntime(502): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
05-28 13:34:09.399: E/AndroidRuntime(502): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:823)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.rInflate(LayoutInflater.java:729)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-28 13:34:09.399: E/AndroidRuntime(502): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.Activity.setContentView(Activity.java:1835)
05-28 13:34:09.399: E/AndroidRuntime(502): at com.nykkos.personalize.screens.SummaryCostScreen.onCreate(SummaryCostScreen.java:37)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.Activity.performCreate(Activity.java:4465)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-28 13:34:09.399: E/AndroidRuntime(502): ... 11 more
05-28 13:34:09.399: E/AndroidRuntime(502): Caused by: java.lang.reflect.InvocationTargetException
05-28 13:34:09.399: E/AndroidRuntime(502): at java.lang.reflect.Constructor.constructNative(Native Method)
05-28 13:34:09.399: E/AndroidRuntime(502): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
05-28 13:34:09.399: E/AndroidRuntime(502): ... 26 more
05-28 13:34:09.399: E/AndroidRuntime(502): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020000 a=-1 r=0x7f020000}
05-28 13:34:09.399: E/AndroidRuntime(502): at android.content.res.Resources.loadDrawable(Resources.java:1899)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.widget.ImageView.<init>(ImageView.java:119)
05-28 13:34:09.399: E/AndroidRuntime(502): at android.widget.ImageView.<init>(ImageView.java:109)
05-28 13:34:09.399: E/AndroidRuntime(502): ... 29 more
05-28 13:34:09.549: W/ActivityManager(77): Force finishing activity com.nykkos.personalize/.screens.SummaryCostScreen
活动中的错误来自:
setContentView(R.layout.summarycost_layout);
xml 文件 summarycost_layout 为:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:orientation="vertical" >
<include
android:id="@+id/includeTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/titlebar_layout" />
<LinearLayout
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" >
<ListView
android:id="@+id/summaryCostListview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="@+id/layoutTotal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="10dp" >
<TextView
android:id="@+id/txtTotal"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Total Cost(0/0)"
android:textColor="@color/blue"
android:textSize="18sp" />
<TextView
android:id="@+id/totalValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="$0"
android:textColor="@color/blue" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/buttonCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_bg"
android:text="@string/cancel"
android:textColor="@android:color/white" />
<Button
android:id="@+id/buttonAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_bg"
android:text="@string/select_all"
android:textColor="@android:color/white" />
<Button
android:id="@+id/buttonAccept"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_bg"
android:text="@string/accept"
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>
上述xml文件中引用的titlebar_layout为:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="@+id/imgBack"
android:layout_width="32dp"
android:layout_height="32dp"
android:onClick="onBackClick"
android:src="@drawable/arrow_back" />
<TextView
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="@android:color/white" />
<ImageView
android:id="@+id/imgForward"
android:layout_width="32dp"
android:layout_height="32dp"
android:onClick="onForwardClick"
android:src="@drawable/arrow_for" />
看来,问题来自<ImageView
titlebar_layout。
我有点迷失在哪里寻找异常的原因。我什至不知道这是否真的是这个布局文件等中的一个问题。
您将如何寻找导致此问题的原因?
任何帮助表示赞赏。