Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.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_Drawable - Fatal编程技术网

Android 打开右侧的两个抽屉布局

Android 打开右侧的两个抽屉布局,android,drawable,Android,Drawable,我想打开右边两个抽屉的布局 drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD); 我无法关闭右侧的两个布局 drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD); 我的xml文件代码是: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/ap

我想打开右边两个抽屉的布局

drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
我无法关闭右侧的两个布局

drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
我的xml文件代码是:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout_job"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- Editext for Search -->

    <LinearLayout
        android:id="@+id/linear1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/linear2"
            android:layout_width="fill_parent"
            android:layout_height="38dp"
            android:gravity="center"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/backbuttonfromsearchscreen"
                android:layout_width="35dip"
                android:layout_height="35dip"
                android:layout_marginTop="5sp"
                android:gravity="left|center"
                android:padding="2dip"
                android:src="@drawable/right_arrow" />

            <TextView
                android:id="@+id/inputSearch"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="50sp"
                android:layout_weight="1"
                android:gravity="right"
                android:text="Results"
                android:textSize="20dip"
                android:textStyle="bold" />

            <Button
                android:id="@+id/layoutLiearAsc"
                android:layout_width="30dip"
                android:layout_height="25dip"
                android:layout_marginRight="10dp"
                android:layout_marginTop="2sp"
                android:background="@drawable/up"
                android:padding="4dip"
                android:textColor="@android:color/black" />

            <TextView
                android:id="@+id/layoutLiearRefine"
                android:layout_width="wrap_content"
                android:layout_height="40dip"
                android:layout_marginTop="1sp"
                android:padding="4dip"
                android:text="Refine"
                android:textColor="#3399FF"
                android:textSize="20dp"
                android:textStyle="bold" />
        </LinearLayout>

        <TextView
            android:id="@+id/result"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="55dp"
            android:layout_marginRight="70dp"
            android:gravity="center"
            android:text="" />

        <TextView
            android:id="@+id/com.example.PolicyImplimentation.Font_arial2"
            android:layout_width="fill_parent"
            android:layout_height="5dp"
            android:layout_marginTop="2sp"
            android:background="@drawable/textline"
            android:visibility="visible" />

        <ListView
            android:id="@+id/list_view_jobsearch"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/linear1"
            android:layout_marginTop="0sp" />
    </LinearLayout>

    <!-- List View -->


    <!-- Right Drawrer -->

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/tab1"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_gravity="right" >

        <RelativeLayout
            android:id="@+id/whatYouWantInRightDrawer"
            android:layout_width="300dp"
            android:layout_height="fill_parent"
            android:background="@android:color/white" >

            <LinearLayout
                android:id="@+id/linear1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="vertical" >

                <LinearLayout
                    android:id="@+id/linear2"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal" >

                    <ImageView
                        android:id="@+id/backbuttonfromsearchscreen"
                        android:layout_width="wrap_content"
                        android:layout_height="27dip"
                        android:layout_marginTop="5sp"
                        android:gravity="left|center"
                        android:padding="2dip"
                        android:src="@drawable/backarrow"
                        android:visibility="invisible" />

                    <Button
                        android:id="@+id/inputSearch"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="5sp"
                        android:layout_weight="1"
                        android:background="@android:color/white"
                        android:gravity="center"
                        android:text="Refine"
                        android:textSize="20dip"
                        android:textStyle="bold" />

                    <Button
                        android:id="@+id/layoutColon"
                        android:layout_width="wrap_content"
                        android:layout_height="27dip"
                        android:background="@android:color/white"
                        android:padding="2dip"
                        android:text="Done"
                        android:textColor="@android:color/holo_blue_dark"
                        android:textStyle="bold" />
                </LinearLayout>

                <TextView
                    android:id="@+id/RefineResult"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginRight="5sp"
                    android:gravity="center"
                    android:text="0 results" />

                <TextView
                    android:id="@+id/com.example.PolicyImplimentation.Font_arial2"
                    android:layout_width="fill_parent"
                    android:layout_height="5dp"
                    android:layout_marginTop="2sp"
                    android:background="@drawable/textline"
                    android:visibility="visible" />

                <ListView
                    android:id="@+id/rightJobDrawer"
                    android:layout_width="280dp"
                    android:layout_height="fill_parent"
                    android:layout_gravity="right"
                    android:background="@android:color/white"
                    android:choiceMode="singleChoice"
                    android:divider="#666666"
                    android:dividerHeight="0.5dp" />

                <Button
                    android:id="@+id/layoutReset"
                    android:layout_width="wrap_content"
                    android:layout_height="27dip"
                    android:background="@android:color/white"
                    android:padding="2dip"
                    android:text="Reset"
                    android:textColor="@android:color/holo_blue_dark"
                    android:textStyle="bold" />
            </LinearLayout>

            <Button
                android:id="@+id/layoutset"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@+id/linear1"
                android:background="@android:color/white"
                android:padding="2dip"
                android:text=""
                android:textColor="@android:color/holo_blue_dark"
                android:textStyle="bold" />

            <!-- you can have many more widgets here like buttons or labels -->
        </RelativeLayout>
    </android.support.v4.widget.DrawerLayout>

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/tab2"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_gravity="right" >

        <RelativeLayout
            android:id="@+id/whatYouWantInRightDrawerLocation"
            android:layout_width="300dp"
            android:layout_height="fill_parent"
            android:background="@android:color/white" >

            <LinearLayout
                android:id="@+id/linear1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="vertical" >

                <LinearLayout
                    android:id="@+id/linear2"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal" >

                    <ImageView
                        android:id="@+id/backbuttonfromsearchscreen"
                        android:layout_width="wrap_content"
                        android:layout_height="27dip"
                        android:layout_marginTop="5sp"
                        android:gravity="left|center"
                        android:padding="2dip"
                        android:src="@drawable/backarrow"
                        android:visibility="invisible" />

                    <Button
                        android:id="@+id/inputSearch"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="5sp"
                        android:layout_weight="1"
                        android:background="@android:color/white"
                        android:gravity="center"
                        android:text="Refine"
                        android:textSize="20dip"
                        android:textStyle="bold" />

                    <Button
                        android:id="@+id/layoutColon"
                        android:layout_width="wrap_content"
                        android:layout_height="27dip"
                        android:background="@android:color/white"
                        android:padding="2dip"
                        android:text="Done"
                        android:textColor="@android:color/holo_blue_dark"
                        android:textStyle="bold" />
                </LinearLayout>

                <TextView
                    android:id="@+id/RefineResult"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginRight="5sp"
                    android:gravity="center"
                    android:text="0 results" />

                <TextView
                    android:id="@+id/com.example.PolicyImplimentation.Font_arial2"
                    android:layout_width="fill_parent"
                    android:layout_height="5dp"
                    android:layout_marginTop="2sp"
                    android:background="@drawable/textline"
                    android:visibility="visible" />

                <ListView
                    android:id="@+id/rightJobDrawer"
                    android:layout_width="280dp"
                    android:layout_height="fill_parent"
                    android:layout_gravity="right"
                    android:background="@android:color/white"
                    android:choiceMode="singleChoice"
                    android:divider="#666666"
                    android:dividerHeight="0.5dp" />

                <EditText
                    android:id="@+id/editTextDialogUserInput"
                    android:layout_width="wrap_content"
                    android:layout_height="27dip"
                    android:background="@android:color/white"
                    android:padding="2dip"
                    android:text="Reset"
                    android:textColor="@android:color/holo_blue_dark"
                    android:textStyle="bold" />
            </LinearLayout>

            <Button
                android:id="@+id/layoutset"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@+id/linear1"
                android:background="@android:color/white"
                android:padding="2dip"
                android:text=""
                android:textColor="@android:color/holo_blue_dark"
                android:textStyle="bold" />

            <!-- you can have many more widgets here like buttons or labels -->
        </RelativeLayout>
    </android.support.v4.widget.DrawerLayout>

</android.support.v4.widget.DrawerLayout>
drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);

我关闭这两个布局的代码是:

drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
mDrawerLayout.openDrawer(右抽屉中需要的内容)

drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
mDrawerLayout.openDrawer(您想要的右抽屉位置)

drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
请帮我解决这个问题

drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);

提前感谢。

我简化了您的视图,使其更易于阅读:

<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"
   >
    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/black"/>
    <!-- The navigation drawer -->
    <FrameLayout android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:clickable="true"
        android:layout_gravity="start"
        android:layout_height="match_parent"
        android:background="@android:color/white"/>

    <!-- The navigation drawer -->
    <FrameLayout android:id="@+id/right_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:clickable="true"
        android:layout_gravity="end"
        android:background="@android:color/white"/>
</android.support.v4.widget.DrawerLayout>
drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);

您基本上希望在同一侧打开两个抽屉,但一个在刷卡时打开,另一个在单击鼠标右键时打开

drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
以下各点也是如此:

drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
  • 写下您的向右滑动导航抽屉,当您向右滑动时,它将打开抽屉

    drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
    
  • 之后,使用按钮打开第二个抽屉,并将其锁定,使其不会在刷卡时打开
  • 您可以使用以下代码锁定抽屉

    drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
    
    打开第二个抽屉的按钮

    drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
    
    Button button =(Button) findviewById(R.id.theid);
    
    并设置点击侦听器,即

    drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);
    
     button.setOnClickListener(new OnClickListener());
    

    希望对您有所帮助

    首先,当打开roght dwaer时,我在第一个右抽屉上有一个按钮,单击按钮我将在同一页上打开第二个右dwaer,如何操作,帮助我使用OpenDrawer()函数。
    drawer.mDrawerLayout.setDrawerLockMode(View.FOCUS_BACKWARD);