我想在抽屜裏面使用相對佈局,這樣我可以包含一個列表視圖和一個網格視圖。收到以下錯誤運行時:抽屜佈局裏面的相對佈局:相對佈局參數不能被抽成抽屜佈局參數
logcat的錯誤:
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.support.v4.widget.DrawerLayout$LayoutParams
XML:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- ListView to display slider menu -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="240dp"
android:layout_height="fill_parent"
android:layout_gravity="start"
android:id="@+id/drawer_relative_layout"
>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:listSelector="@drawable/list_selector"
android:background="@color/list_background"
/>
<GridView
android:id="@+id/images_drawer"
android:layout_width="240dp"
android:layout_height="fill_parent"
android:layout_below="@id/left_drawer"
android:layout_gravity="left"
android:choiceMode="singleChoice"
android:background="@color/list_background"
android:layout_margin="5dp"
android:columnWidth="100dp"
android:drawSelectorOnTop="true"
android:numColumns="2"
android:stretchMode="columnWidth"
android:horizontalSpacing="5dp"
android:verticalSpacing="5dp"
/>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
後完整的錯誤堆棧跟蹤 – Javanator
嘿,是你能解決這個? –