我已成功實現PagerSlidingTabStrip(它包含viewpager)。 然後,我把上面的listview與DrawerLayout成功(yehh)。DrawerLayout(帶FrameLayout)在方向更改時崩潰
然後,我用一個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
發佈您的logcat – user2450263