0

这是我正在使用的结构

<FrameLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <AbsoluteLayout android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:id="@+id/abs_layout">
            <ImageView    />
            <ImageView   />
    </AbsoluteLayout>

    <ImageView android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon"/>

</FrameLayout>

上面的结构工作正常,但是当我使用下面的结构时会出错

<FrameLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/icon"/>

    <AbsoluteLayout android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:id="@+id/abs_layout">
            <ImageView    />
            <ImageView   />
    </AbsoluteLayout>
</FrameLayout>

错误日志:

10-14 10:35:54.134: E/AndroidRuntime(13044): FATAL EXCEPTION: main
10-14 10:35:54.134: E/AndroidRuntime(13044): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.d/com.example.d.DMainActivity}: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.AbsoluteLayout
10-14 10:35:54.134: E/AndroidRuntime(13044):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
10-14 10:35:54.134: E/AndroidRuntime(13044):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
4

0 回答 0