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后面要紧跟你的包名,加黑处为改动处

  • 相关阅读:
    写给理工科人看的乐理(一)声学基础
    魔方最少记忆还原法
    甲乙两人互猜数字(鬼谷子问题)的逻辑推理与算法建模
    模板元编程实现素数判定
    UVa OJ 194
    UVa OJ 175
    UVa OJ 197
    UVa OJ 180
    UVa OJ 140
    判断input或者div.span等标签是否存在
  • 原文地址:https://www.cnblogs.com/zhoushenglei/p/7218210.html
Copyright © 2011-2022 走看看