Android 运行应用程序时,在相对布局中未找到资源异常

Android 运行应用程序时,在相对布局中未找到资源异常,android,Android,我正在创建相对布局,它看起来很好,当时没有给出任何错误。但是当我试图运行这个应用程序时,我在运行时得到了错误,如下所述 错误是: 07-03 23:04:55.420: D/AndroidRuntime(20456): Shutting down VM 07-03 23:04:55.430: W/dalvikvm(20456): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 07-

我正在创建相对布局,它看起来很好,当时没有给出任何错误。但是当我试图运行这个应用程序时,我在运行时得到了错误,如下所述

错误是:

   07-03 23:04:55.420: D/AndroidRuntime(20456): Shutting down VM
    07-03 23:04:55.430: W/dalvikvm(20456): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    07-03 23:04:55.491: E/AndroidRuntime(20456): FATAL EXCEPTION: main
    07-03 23:04:55.491: E/AndroidRuntime(20456): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.customdialog/com.customdialog.CustomDialogExample}: android.view.InflateException: Binary XML file line #3: Error inflating class android.widget.RelativeLayout
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.os.Handler.dispatchMessage(Handler.java:99)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.os.Looper.loop(Looper.java:123)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.app.ActivityThread.main(ActivityThread.java:4627)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at java.lang.reflect.Method.invokeNative(Native Method)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at java.lang.reflect.Method.invoke(Method.java:521)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at dalvik.system.NativeStart.main(Native Method)
    07-03 23:04:55.491: E/AndroidRuntime(20456): Caused by: android.view.InflateException: Binary XML file line #3: Error inflating class android.widget.RelativeLayout
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.LayoutInflater.createView(LayoutInflater.java:513)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.app.Dialog.setContentView(Dialog.java:421)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at com.customdialog.CustomizeDialog.<init>(CustomizeDialog.java:24)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at com.customdialog.CustomDialogExample.onCreate(CustomDialogExample.java:16)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    ... 11 more
    07-03 23:04:55.491: E/AndroidRuntime(20456): Caused by: java.lang.reflect.InvocationTargetException
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.widget.RelativeLayout.<init>(RelativeLayout.java:170)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at java.lang.reflect.Constructor.constructNative(Native Method)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.LayoutInflater.createView(LayoutInflater.java:500)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    ... 22 more
    07-03 23:04:55.491: E/AndroidRuntime(20456): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f06000b a=-1 r=0x7f06000b}
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.content.res.Resources.loadDrawable(Resources.java:1681)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.View.<init>(View.java:1885)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.View.<init>(View.java:1834)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    at android.view.ViewGroup.<init>(ViewGroup.java:285)
    07-03 23:04:55.491: E/AndroidRuntime(20456):    ... 26 more
下面是创建对话框的CustomizeDialog.class

public class CustomizeDialog extends Dialog{

    Button dialogButtonYes;
    Button dialogButtonNo;
    TextView textView,titleText,customtitle;
    public CustomizeDialog(Context context){
        super(context);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        /** Design the dialog in main.xml file */
        setContentView(R.layout.relative);
        dialogButtonYes = (Button) findViewById(R.id.buttonCustomDialogYes);
        dialogButtonNo = (Button) findViewById(R.id.buttonCustomDialogNo);
        textView = (TextView) findViewById(R.id.textViewCustomTitle);
        //customtitle.setText(title);
        textView.setText("ffg");
}
}
相对的.xml布局xml文件是:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@style/HeadingTheme"
    android:layout_centerHorizontal="true" >
    <TextView
        android:id="@+id/textViewCustomTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="ABCD"/>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textViewCustomTitle"
        android:orientation="horizontal"
        android:paddingBottom="1.0dip"
        android:paddingLeft="4.0dip"
        android:paddingRight="4.0dip"
        android:paddingTop="5.0dip" >
        <Button
            android:id="@+id/buttonCustomDialogYes"
            android:layout_width="0.0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1.0"
            android:text="Yes" />
        <Button
        android:id="@+id/buttonCustomDialogNo"
           android:layout_width="0.0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1.0"
            android:text="No" />
    </LinearLayout>
</RelativeLayout>

请让我知道是否有人面临这个问题,以及他们试图解决这个问题的解决方案


提前谢谢。

我想这是在抱怨你的背景(
android:background


尝试从您的RelativeLayout中删除该属性,以确保这就是问题所在。如果是这样,请检查给定资源的情况。

我认为它在抱怨您的背景(
android:background


尝试从您的RelativeLayout中删除该属性,以确保这就是问题所在。如果是这样,请检查给定资源的情况。

是的,这是我面临的问题,现在已解决。谢谢。。。但是你能告诉我为什么它在相对论上有吉文错误吗。在线性布局中完美地工作。这真的很奇怪。我没有工作背景,所以我不知道。对不起,是的,这是我面临的问题,现在又解决了。谢谢。。。但是你能告诉我为什么它在相对论上有吉文错误吗。在线性布局中完美地工作。这真的很奇怪。我没有工作背景,所以我不知道。我很抱歉。
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@style/HeadingTheme"
    android:layout_centerHorizontal="true" >
    <TextView
        android:id="@+id/textViewCustomTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="ABCD"/>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textViewCustomTitle"
        android:orientation="horizontal"
        android:paddingBottom="1.0dip"
        android:paddingLeft="4.0dip"
        android:paddingRight="4.0dip"
        android:paddingTop="5.0dip" >
        <Button
            android:id="@+id/buttonCustomDialogYes"
            android:layout_width="0.0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1.0"
            android:text="Yes" />
        <Button
        android:id="@+id/buttonCustomDialogNo"
           android:layout_width="0.0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1.0"
            android:text="No" />
    </LinearLayout>
</RelativeLayout>
Resource is not a drawable.