【发布时间】:2013-07-13 20:58:46
【问题描述】:
我正在使用navigation drawer 开发一个 andorid 应用程序,并且我有一个这样的 contentview 布局:
<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">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:dividerHeight="0dp"
android:divider="@android:color/transparent"
android:background="@color/default_color"/>
</android.support.v4.widget.DrawerLayout>
所以我可以在导航抽屉项目点击时添加和替换片段。到目前为止一切正常。
但在一种情况下,单击导航抽屉上的项目时,我需要显示两个片段而不是一个(就像 listFragment 和详细信息片段一样)。我该怎么做?我应该在框架布局中添加两个片段吗?但是怎么做?还是应该用不同的 drawerLayout 更改 contentView ?如果是,我该怎么做?
【问题讨论】:
标签: android android-fragments android-framelayout navigation-drawer