zoukankan      html  css  js  c++  java
  • 自定义View的ToolBar布局报错Error:(2) No resource identifier found for attribute 'context' in package 'c

    这是由于你的自定义xmlns出错,

    先上代码:

    出错的布局文件

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/apk/res-auto"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="ca.sd.zsl.toolbartest.MainActivity">

    改好的布局文件:

    <android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.ca.sd.zsl.toolbartest"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="ca.sd.zsl.toolbartest.MainActivity">

    清单文件

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="ca.sd.zsl.toolbartest">

    自定义View界面时,命名空间需要自己定义,就是xmlns属性,首先Android开头的是系统自带的,你的各种系统自带空间就是他控制,接下来就是我们自己的命名空间了,

    我给它取名tool,名字你任意取,然后Android后面要紧跟你的包名,加黑处为改动处

  • 相关阅读:
    P1144 最短路计数
    P2966 [USACO09DEC]牛收费路径Cow Toll Paths
    P2419 [USACO08JAN]牛大赛Cow Contest
    P1462 通往奥格瑞玛的道路
    P1346 电车
    P1339 [USACO09OCT]热浪Heat Wave
    P1418 选点问题
    P1330 封锁阳光大学
    P1182 数列分段Section II
    P2661 信息传递
  • 原文地址:https://www.cnblogs.com/zhoushenglei/p/7218210.html
Copyright © 2011-2022 走看看