私はアンドロイド開発の初心者です。画像ボタンを押した後、新しいアクティビティを開始しようとしています。しかし、エミュレーターで実行しようとすると、常にエラーが発生します:「AppNameが停止しました」。
ここに私のコードがあります: 画像ボタン:
<ImageButton
android:id="@+id/FirstAidButton"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_toLeftOf="@+id/BodyMassIndex"
android:background="@null"
android:contentDescription="@string/firstaid"
android:src="@drawable/firstaid"
android:onClick="fatTutorial" />
ジャワ:
public void fatTutorial(View view) {
Intent intent = new Intent(this, FirstAidTutorial.class);
startActivity(intent);
}
マニフェスト:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dr.droid"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/drdroid"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Home"
android:label="@string/title_activity_home" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:label="@string/title_text" android:name="dr.droid.FirstAidTutorial"/>
</application>
</manifest>
受信クラス(FirstAidTutorial):
@Override
public void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
}
LogCat:
08-20 18:13:28.428: E/Trace(633): error opening trace file: No such file or directory (2)
08-20 18:13:28.898: D/dalvikvm(633): GC_FOR_ALLOC freed 256K, 4% free 8140K/8455K, paused 66ms, total 71ms
08-20 18:13:29.008: D/dalvikvm(633): GC_FOR_ALLOC freed 194K, 5% free 8254K/8647K, paused 40ms, total 41ms
08-20 18:13:29.619: I/Choreographer(633): Skipped 81 frames! The application may be doing too much work on its main thread.
08-20 18:13:29.738: D/gralloc_goldfish(633): Emulator without GPU emulation detected.
08-20 18:13:32.068: D/AndroidRuntime(633): Shutting down VM
08-20 18:13:32.098: W/dalvikvm(633): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-20 18:13:32.388: E/AndroidRuntime(633): FATAL EXCEPTION: main
08-20 18:13:32.388: E/AndroidRuntime(633): java.lang.RuntimeException: Unable to start activity ComponentInfo{dr.droid/dr.droid.FirstAidTutorial}: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.os.Handler.dispatchMessage(Handler.java:99)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.os.Looper.loop(Looper.java:137)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.ActivityThread.main(ActivityThread.java:4745)
08-20 18:13:32.388: E/AndroidRuntime(633): at java.lang.reflect.Method.invokeNative(Native Method)
08-20 18:13:32.388: E/AndroidRuntime(633): at java.lang.reflect.Method.invoke(Method.java:511)
08-20 18:13:32.388: E/AndroidRuntime(633): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-20 18:13:32.388: E/AndroidRuntime(633): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-20 18:13:32.388: E/AndroidRuntime(633): at dalvik.system.NativeStart.main(Native Method)
08-20 18:13:32.388: E/AndroidRuntime(633): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class <unknown>
08-20 18:13:32.388: E/AndroidRuntime(633): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
08-20 18:13:32.388: E/AndroidRuntime(633): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-20 18:13:32.388: E/AndroidRuntime(633): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.Activity.setContentView(Activity.java:1867)
08-20 18:13:32.388: E/AndroidRuntime(633): at dr.droid.FirstAidTutorial.onCreate(FirstAidTutorial.java:13)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.Activity.performCreate(Activity.java:5008)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-20 18:13:32.388: E/AndroidRuntime(633): ... 11 more
08-20 18:13:32.388: E/AndroidRuntime(633): Caused by: java.lang.reflect.InvocationTargetException
08-20 18:13:32.388: E/AndroidRuntime(633): at java.lang.reflect.Constructor.constructNative(Native Method)
08-20 18:13:32.388: E/AndroidRuntime(633): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-20 18:13:32.388: E/AndroidRuntime(633): ... 24 more
08-20 18:13:32.388: E/AndroidRuntime(633): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f060000 a=-1 r=0x7f060000}
08-20 18:13:32.388: E/AndroidRuntime(633): at android.content.res.Resources.loadColorStateList(Resources.java:2035)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.widget.TextView.<init>(TextView.java:772)
08-20 18:13:32.388: E/AndroidRuntime(633): at android.widget.TextView.<init>(TextView.java:442)
08-20 18:13:32.388: E/AndroidRuntime(633): ... 27 more
firstaidtutorial.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:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/AnimalBite"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="@string/animalbite"
android:textColor="#CC0000"
android:textColorHint="@style/AppTheme"
android:textSize="25dp" />
<TextView
android:id="@+id/ChokingInfant"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="@string/chokinginfant"
android:textColor="#CC0000"
android:textSize="25dp" />
<TextView
android:id="@+id/ChokingChild"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="@string/chokingchild"
android:textColor="#CC0000"
android:textSize="25dp" />
<TextView
android:id="@+id/ChokingAdult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="@string/chokingadult"
android:textColor="#CC0000"
android:textSize="25dp" />
<TextView
android:id="@+id/Convulsion"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="@string/convulsion"
android:textColor="#CC0000"
android:textSize="25dp" />
<TextView
android:id="@+id/CPRAdult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/cpradult"
android:padding="5dp"
android:textColor="#CC0000"
android:textSize="25dp" />
<TextView
android:id="@+id/CPRInfant"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/cprinfants"
android:padding="5dp"
android:textColor="#CC0000"
android:textSize="25dp" />
<TextView
android:id="@+id/HeimlichManeuver"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/heimlichmaneuver"
android:padding="5dp"
android:textColor="#CC0000"
android:textSize="25dp" />
<TextView
android:id="@+id/MinorBurn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/minorburn"
android:padding="5dp"
android:textColor="#CC0000"
android:textSize="25dp" />
<TextView
android:id="@+id/MinorCut"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/minorcut"
android:padding="5dp"
android:textColor="#CC0000"
android:textSize="25dp" />
</LinearLayout>
何か案は?また、その新しいアクティビティの xml を作成して、デザイン/レイアウトを配置できるようにするにはどうすればよいですか。ありがとう!