Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.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,我有一个抽屉布局工作得很好,但我想通过从屏幕的左侧拖动到右侧来禁用打开,我该怎么做 当前布局: <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.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">

        <fragment 
                  class="net.MyFragment"
                  android:id="@+id/fragment_reading"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent" >
        </fragment>
    </FrameLayout>
    <!-- The navigation drawer -->

    <ExpandableListView
            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:cacheColorHint="#000000"
            />

    />

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

您的抽屉布局在哪里

这会锁上你的抽屉

在您的按钮上单击,您可以使用打开和关闭它

if (mDrawerLayout.isDrawerOpen(mDrawerList))
    mDrawerLayout.closeDrawer(mDrawerList);
else
    mDrawerLayout.openDrawer(mDrawerList);

其中mDrawerList是您的可扩展列表视图

在创建期间将其设置为锁定模式锁定关闭状态,并以编程方式打开/关闭。
if (mDrawerLayout.isDrawerOpen(mDrawerList))
    mDrawerLayout.closeDrawer(mDrawerList);
else
    mDrawerLayout.openDrawer(mDrawerList);