为什么我会收到错误,当我使用XML的不同背景
我有3个活动,我想用不同的背景的。但是当我这样做我得到这个,但是我得到这个错误,如果我只用不同的背景2活动,然后应用程序的作品
I have 3 activities which I want to use different backgrounds with. but when i do this i get this i get this error however if i only use different backgrounds on 2 activities then the app works
11-20 13:40:25.855:E / AndroidRuntime(849):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.medepad.community_virtual_ward / com.medepad.community_virtual_ward.Temperature}:android.view。 InflateException:二进制XML文件中的行#2:错误充气类
11-20 13:40:25.855: E/AndroidRuntime(849): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.medepad.community_virtual_ward/com.medepad.community_virtual_ward.Temperature}: android.view.InflateException: Binary XML file line #2: Error inflating class
该活动被称为主的欢迎和温度。
the activities are called main welcome and temperature.
code主 XML
code for main xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="@drawable/main" >
<TextView
android:id="@+id/textView1"
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>
Java的code
java code
package com.medepad.community_virtual_ward;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
int a;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView start = (TextView)findViewById(R.id.textView1);
start.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent welcome= new Intent (this,Welcome.class);
startActivity(welcome);
}
}
code温度
code for 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>
Java的code
java code
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 code
welcome xml code
<?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>
Java的code
java code
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);
}
}
为什么会出现这个错误,我能做些什么来使用我想要的背景是多少?
why am i getting this error and what can i do to use the amount of backgrounds i want?
请检查下面的文件
temperature.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>
和你要么定义在 temperature.xml 和的main.xml
A绘制资源$ C> RES /绘制文件夹或已添加的图像资源,名称温度
和主
在你的Android项目。
and you have either defined a drawable resource with name temperature.xml
and main.xml
under res/drawable
folder or you have added image resources with name temperature
and main
in your Android project.