Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 最好的方法包括一个布局,其中包含多个子布局和一个导航抽屉_Android_Navigation Drawer - Fatal编程技术网

Android 最好的方法包括一个布局,其中包含多个子布局和一个导航抽屉

Android 最好的方法包括一个布局,其中包含多个子布局和一个导航抽屉,android,navigation-drawer,Android,Navigation Drawer,简而言之,我的问题是:如何在导航抽屉中包含复杂的布局 我有一个我的主要活动与viewpager,片段,这里是我的主要活动最初的代码 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >

简而言之,我的问题是:如何在导航抽屉中包含复杂的布局

我有一个我的主要活动与viewpager,片段,这里是我的主要活动最初的代码

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

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1" >

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignBottom="@+id/pager"
        android:gravity="center|bottom"
        android:text="GGG" />
 </RelativeLayout>

 <fragment
    android:id="@+id/text_fragment"
    android:name="com.sample.fragment.HomeButton"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1" />

</LinearLayout>

现在我想介绍一下这个。我想出了两种方法

1.在导航抽屉的框架布局(内容框架)中包含上述布局(我尝试过,但没有成功)


2.创建一个新的片段并将上面的布局包括在内,现在我们的mainactivity包含一个新的片段+导航抽屉


请告诉我怎么做。

我试过了,但对我不起作用-你试过的时候到底发生了什么?是的,我在上面提到的第一种方法dat中试过,但它在视图(布局)中抛出了一个错误。我想问题应该出在嵌套布局上。
<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
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

</FrameLayout>


<ListView
    android:id="@+id/left_drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#111"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout>