2

この例外はどういう意味ですか?

07-05 12:09:11.788: W/dalvikvm(445): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-05 12:09:11.808: E/AndroidRuntime(445): FATAL EXCEPTION: main
07-05 12:09:11.808: E/AndroidRuntime(445): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.a2zunitconverter.miniproject/com.a2zunitconverter.miniproject.weight}: java.lang.ClassCastException: android.widget.LinearLayout
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.os.Looper.loop(Looper.java:123)
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-05 12:09:11.808: E/AndroidRuntime(445):  at java.lang.reflect.Method.invokeNative(Native Method)
07-05 12:09:11.808: E/AndroidRuntime(445):  at java.lang.reflect.Method.invoke(Method.java:507)
07-05 12:09:11.808: E/AndroidRuntime(445):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-05 12:09:11.808: E/AndroidRuntime(445):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-05 12:09:11.808: E/AndroidRuntime(445):  at dalvik.system.NativeStart.main(Native Method)
07-05 12:09:11.808: E/AndroidRuntime(445): Caused by: java.lang.ClassCastException: android.widget.LinearLayout
07-05 12:09:11.808: E/AndroidRuntime(445):  at com.a2zunitconverter.miniproject.weight.onCreate(weight.java:31)
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-05 12:09:11.808: E/AndroidRuntime(445):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-05 12:09:11.808: E/AndroidRuntime(445):  ... 11 more
07-05 12:09:15.538: D/dalvikvm(454): GC_EXTERNAL_ALLOC freed 49K, 53% free 2560K/5379K, external 2076K/2137K, paused 56ms

ここに私のxmlコードがあります:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="fill_parent" 
    android:background="@drawable/weight4">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="@string/weight"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#ffffff" />

        <EditText
            android:id="@+id/wquery"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:inputType="numberDecimal"
            android:text="@string/value" >

            <requestFocus />
        </EditText>

        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/label2"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#ffffff" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <Spinner
                android:id="@+id/convertfrom"
                android:layout_width="126dp"
                android:layout_height="wrap_content" >
            </Spinner>

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="34dp"
                android:layout_height="61dp"
                android:background="#cccccc"
                android:src="@drawable/arrows" />

            <Spinner
                android:id="@+id/convertto"
                android:layout_width="137dp"
                android:layout_height="wrap_content" >
            </Spinner>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/back1"
            android:layout_width="match_parent"
            android:layout_height="248dp"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView3"
                android:layout_width="213dp"
                android:layout_height="wrap_content"
                android:text="@string/result"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#ffffff" />

            <TextView
                android:id="@+id/result"
                android:layout_width="269dp"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:textColor="#66cc00" />

            <ImageView
                android:id="@+id/exit"
                android:layout_width="74dp"
                android:layout_height="match_parent"
                android:src="@drawable/back" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>
4

3 に答える 3

3

レイアウト xml を変更した後、Eclipse でこのエラーが発生することがあります。Eclipse で「Clean Project」を作成してみてください。それは私を助けます。

于 2012-09-06T11:12:28.117 に答える