【发布时间】:2014-02-18 23:25:52
【问题描述】:
我已经成功实现了 PagerSlidingTabStrip(它包含一个 viewpager)。 然后,我成功地在上面放置了一个带有列表视图的 DrawerLayout (yehh)。
然后,我用 FrameLayout 替换 Listview,里面有一个片段,以便在我的抽屉中有一个片段。
它正在工作,但在方向更改时崩溃。我不知道为什么。
这是工作的 xml。
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/theme_color" >
<!-- The main content view -->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blanccasse" >
<com.astuetz.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="48dip"
android:background="@drawable/background_tabs" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tabs"
android:layout_margin="5dp"
tools:context=".MainActivity" />
</RelativeLayout>
<!-- The navigation drawer -->
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
如果我用
替换列表视图 <FrameLayout
android:id="@+id/drawer_layout"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/gris" >
</FrameLayout>
它在方向改变时崩溃。
有什么想法吗??谢谢。
编辑:
logcat 是: java.lang.RuntimeException:无法启动活动 ComponentInfo{com.xxx.xxx/com.xxx.xxx.MainActivity}:java.lang.ClassCastException:android.view.AbsSavedState$1 无法转换为 android.support.v4.widget .DrawerLayout$SavedState
【问题讨论】: