No resource identifier found for attribute 'headerLayout' in package错误解决方法


我在使用NavigationView这个控件的时候出现了以下的错误:

Error:(2) No resource identifier found for attribute 'headerLayout' in package 'com.example.administrator.learndrewablelayout'

Error:(2) No resource identifier found for attribute 'menu' in package 'com.example.administrator.learndrewablelayout'

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'F:\Android\SDK\build-tools\24.0.2\aapt.exe'' finished with non-zero exit value 1


我的xml文件内容如下:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.NavigationView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/nv_main_menu"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:layout_gravity="start"
    android:clickable="true"
    app:headerLayout="@layout/activity_main_menu_head"
    app:menu="@menu/activity_main_menu_item">
</android.support.design.widget.NavigationView>


解决方法:

在build.gradle中添加如下:

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


在我的build.gradle文件中是这样的

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:appcompat-v7:24.1.1'
}
 

添加上面那一句之后我的问题就可以解决了。。。。。。

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值