找不到属性“菜单”的资源标识符

时间:2015-11-08 22:03:42

标签: android xml

我正在尝试在我的应用中实现导航抽屉,但当我尝试引用我的'@ menu / navigationdraweritems'文件时,我收到错误:

Error:(26) No resource identifier found for attribute 'menu' in package 'com.t99sdevelopment.centralized'

这是我的XML ......

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <include
            layout="@layout/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@+id/flContent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nvView"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@android:color/white"
        app:menu="@menu/navigationdraweritems" />
</android.support.v4.widget.DrawerLayout>

也...

My gradle dependency: com.android.support:appcompat-v7:23.1.0

有什么想法吗?

1 个答案:

答案 0 :(得分:12)

要使android.support.design.widget.NavigationView起作用,您需要在build.gradle中添加设计依赖项:

 compile 'com.android.support:design:23.1.0'