0

首先我是新来的android,非常抱歉,我有2个布局:第一个包含碎片;第二个是导航抽屉布局。如何将碎片布局与导航抽屉布局结合

如何将两个布局整合到一个布局中?我想有主要布局包含两种布局,请帮助..

的第一个布局:

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

    <fragment android:name="com.example.HomeFragment" 
       android:id="@+id/selectionFragment" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
    <fragment android:name="com.example.SplashFragment" 
       android:id="@+id/splashFragment" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
    <fragment android:name="com.facebook.widget.UserSettingsFragment" 
       android:id="@+id/userSettingsFragment" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
</LinearLayout> 

第二导航抽屉布局:

<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 --> 
    <ListView 
     android:id="@+id/list_slidermenu" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:choiceMode="singleChoice" 
     android:divider="@color/list_divider" 
     android:dividerHeight="1dp"   
     android:listSelector="@drawable/list_selector" 
     android:background="@color/list_background"/> 
</android.support.v4.widget.DrawerLayout> 

回答

0

你的第二个布局声明了一个FrameLayout元素。该元素用于动态集成Fragment。这种做法在this page的官方Android文档中有解释。

+0

亲爱的杰拉德Paligot对不起,但我是新来的Android我没有检查片段链接,你发送,所以我从链接,我可以但我的碎片内Framlayout?并分配哪些片段将从MainActivity出现? – user2319947