Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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_Android Drawer - Fatal编程技术网

Android 抽屉布局不工作

Android 抽屉布局不工作,android,android-drawer,Android,Android Drawer,这是navigation_menu.xml <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/home" android:title="Home"/> <item android:id="@+id/myorders" android

这是navigation_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@+id/home"
    android:title="Home"/>

<item android:id="@+id/myorders"
    android:title="My Orders"/>
<item android:id="@+id/myplaces"
    android:title="My Places"/>

<item android:id="@+id/mensettings"
    android:title="Settings"/>

</menu>
请帮帮我,因为这项工作对我来说非常重要,请帮帮我。 抽屉布局工作不正常

请尝试使用此选项

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:layout_gravity="start"
    tools:context=".Setting">

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


</android.support.constraint.ConstraintLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:headerLayout="@layout/header"
    app:menu="@menu/nav_menu"
    android:layout_gravity="start"
    android:fitsSystemWindows="true" />

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

//这是文件导航\u menu.xml的名称//
//首先你需要做一份菜单
//这里是与项目相关的东西,如id和标题
//这里是与项目相关的东西,如id和标题
//然后,您需要在抽屉中添加此布局
//mainactivity.xml代码
//首先使用导航菜单,然后执行以下过程
//在android id标签中,您可以添加菜单栏,并且需要添加两个依赖项
//依赖一些
//实现'com.android.support:design:27.1.1'
//实现'com.android.support:support compat:27.1.1'
https://www.youtube.com/watch?v=AS92bq3XxkA
//
在你遇到问题之前,你可以点击下面的链接
添加此

dependencies {
    implementation "androidx.drawerlayout:drawerlayout:1.1.1"
}

在build.gradle文件中

您得到了什么?不需要保留同一设计库的多个条目。删除此
实现'com.android.support:design:28.0.0-alpha1'
您说过您在抽屉布局上有问号,您能附上导航抽屉的屏幕截图吗?图片已在开始时附上
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:layout_gravity="start"
    tools:context=".Setting">

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


</android.support.constraint.ConstraintLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:headerLayout="@layout/header"
    app:menu="@menu/nav_menu"
    android:layout_gravity="start"
    android:fitsSystemWindows="true" />

</android.support.v4.widget.DrawerLayout>
// this is the name of file navigation_menu.xml//
//firstly you need to make a menu
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

        <item >
     //   here item related things like id and title

        </item>
        <item >
          //   here item related things like id and title

        </item>



</menu>
//then you need to add this in drawer layout

//mainactivity.xml code


<android.support.v4.widget.DrawerLayout>

 //first you take navigation menu and then perform the below process
  //in  android id tag you can add menu bar and you need to add two dependency
//dependency some
  //implementation 'com.android.support:design:27.1.1'
  // implementation 'com.android.support:support-compat:27.1.1'
https://www.youtube.com/watch?v=AS92bq3XxkA


//




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


 till you get some problem you can go on the below link
dependencies {
    implementation "androidx.drawerlayout:drawerlayout:1.1.1"
}