Android 为什么在xml中使用不同的背景时会出错

Android 为什么在xml中使用不同的背景时会出错,android,xml,android-layout,android-intent,Android,Xml,Android Layout,Android Intent,我有3个活动,我想使用不同的背景。但是当我这样做的时候,我得到了这个错误,但是如果我只在两个活动中使用不同的背景,那么这个应用程序就可以工作了 11-20 13:40:25.855:E/AndroidRuntime(849):java.lang.RuntimeException:无法启动活动组件信息{com.medepad.community_virtual_ward/com.medepad.community_virtual_ward.Temperature}:android.view.Inf

我有3个活动,我想使用不同的背景。但是当我这样做的时候,我得到了这个错误,但是如果我只在两个活动中使用不同的背景,那么这个应用程序就可以工作了

11-20 13:40:25.855:E/AndroidRuntime(849):java.lang.RuntimeException:无法启动活动组件信息{com.medepad.community_virtual_ward/com.medepad.community_virtual_ward.Temperature}:android.view.InflateException:二进制XML文件行#2:膨胀类时出错

这些活动被称为主要欢迎活动和温度活动

主设备代码 xml

温度代码

<?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="match_parent"
    android:orientation="vertical"
    android:background="@drawable/temperature" >

</LinearLayout>
欢迎使用xml代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/welcome" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="400dp"
        android:layout_marginTop="115dp"
        android:text="TextView"
        android:textColor="#000000"
        android:textSize="40dp" />

</RelativeLayout>

为什么会出现此错误?如何使用所需的背景量?

第一个XML文件的末尾有一个额外的
请检查以下文件

temperature.xml

确保它有以下内容

<?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="match_parent"
    android:orientation="vertical"
    android:background="@drawable/temperature" >

</LinearLayout>


你要么在
res/drawable
文件夹下定义了一个名为
temperature.xml
main.xml
的可绘制资源,要么在你的Android项目中添加了名为
temperature
main
的图像资源。

你能发布代码吗?发布你的xml和我所做的任何相关代码你能帮忙吗请试着去掉“你有没有名为“main”的可提取资源”和“res/…”下的“temperature”之间的空格。。。“?对不起,伙计们,我给你们的代码是有效的,我现在已经把它编辑成无效的。不同之处在于,您会注意到每个xml文件的背景都设置为“我的可绘制文件夹”中的不同png文件。你能帮我吗?你指的是哪个文件,第一个叫做main runs的文件,它不能帮助我回答我的问题。对不起,伙计们,我给了你们一个有效的代码,我现在把它编辑成了一个无效的。不同之处在于,您会注意到每个xml文件的背景都设置为“我的可绘制文件夹”中的不同png文件。你能帮助我吗?
package com.medepad.community_virtual_ward;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class Temperature extends Activity implements OnClickListener {


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.temperature);
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/welcome" >

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="400dp"
        android:layout_marginTop="115dp"
        android:text="TextView"
        android:textColor="#000000"
        android:textSize="40dp" />

</RelativeLayout>
package com.medepad.community_virtual_ward;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class Welcome extends Activity implements OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome);
        TextView next= (TextView)findViewById(R.id.textView2);
        next.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Intent temperature= new Intent(this, Temperature.class);
        startActivity(temperature);
    }
}
<?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="match_parent"
    android:orientation="vertical"
    android:background="@drawable/temperature" >

</LinearLayout>