我是Android的新手,并试图制作简单的应用程序。我正在尝试在Android设备上运行我的应用程序,但它正在崩溃evrytime。请帮忙。
这是我的清单文件。
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Inspection"
android:label="@string/title_activity_inspection"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
</application>
主要活动类
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
public void onClickemergency(View view){
Intent intent = new Intent(this, Inspection.class);
startActivity(intent);
}
}
主要活动Xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="#ffffff"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff2629"
android:text="@string/breaks"
android:drawableRight="@drawable/news"
android:id="@+id/button"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#ffffff"
android:textSize="20dp"
android:paddingEnd="20dp"
android:onClick="onClickemergency"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="150dp"
android:id="@+id/imageView"
android:src="@drawable/check"
android:layout_below="@+id/button"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/checks"
android:background="#1B9AF7"
android:textColor="#ffffff"
android:id="@+id/button2"
android:layout_below="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textSize="20sp"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="150dp"
android:id="@+id/imageView2"
android:src="@drawable/bev"
android:layout_above="@+id/button3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#1B9AF7"
android:textColor="#ffffff"
android:text="@string/pap"
android:textSize="20sp"
android:id="@+id/button3"
android:layout_alignParentBottom="true"
enter code here android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
Logcat文件
Unable to start activity ComponentInfo{com.androidbegin.carpiko/com.androidbegin.carpiko.MainActivity}: android.view.InflateException: Binary XML file line #47: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2192)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2241)
at android.app.ActivityThread.access$800(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1204)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5049)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)