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

自定义View的ToolBar布局报错Error:(2) No resource identifier found for attribute 'context' in package 'c

时间: 2024-08-02 15:14:09

自定义View的ToolBar布局报错Error:(2) No resource identifier found for attribute 'context' in package 'c的相关文章

Error:(108) No resource identifier found for attribute &#39;style&#39; in package &#39;android&#39;

Error:(108) No resource identifier found for attribute 'style' in package 'android' 解决方案: 这是错误的写法: android:style="?android:attr/progressBarStyleHorizontal" /> 去掉android:这个namespace就行了 正确写法如下: style="?android:attr/progressBarStyleHorizont

Error:(12) No resource identifier found for attribute &#39;titles&#39; in package &#39;com.itheima52.mobilesafe5

http://stackoverflow.com/questions/5819369/error-no-resource-identifier-found-for-attribute-adsize-in-package-com-googl# Error:(12) No resource identifier found for attribute 'titles' in package 'com.itheima52.mobilesafe5

安卓错误:error: No resource identifier found for attribute &#39;desc_on&#39; in package &#39;com.

错误原因: 在网上查找错误原因的时候,有文章说这是因为我的布局文件的命名空间没有添加有包名的那个命名空间,可是我检查布局文件完毕之后,发现我已经添加了,但是还是报这个异常错误,我的命名空间为:xmlns:myview="http://schemas.android.com/apk/res/com.example.settingView.view";后来我在另外一篇博文上终于发现了自己的错误原因,这个命名空间后面包名我添加错误了,命名空间后面的包名应该是AndroidManifest.x

error: No resource identifier found for attribute &#39;desc_on&#39; in package &#39;com.

错误原因: 在网上查找错误原因的时候,有文章说这是因为我的布局文件的命名空间没有添加有包名的那个命名空间,可是我检查布局文件完毕之后,发现我已经添加了,但是还是报这个异常错误,我的命名空间为:xmlns:myview="http://schemas.android.com/apk/res/com.example.settingView.view";后来我在另外一篇博文上终于发现了自己的错误原因,这个命名空间后面包名我添加错误了,命名空间后面的包名应该是AndroidManifest.x

error: No resource identifier found for attribute &#39;format24Hour&#39; in package &#39;android&#39;

问题描述:这是在引入Android SDK api level 17中的ApiDemos时,报的错误,但是这个属性明明就是android自带的,怎么会报这种错误呢?百思不得其解,后来改了一下配置就好了,把Target  Api改成17就行了. 其实类似的问题都可以往这个方向思考:Android不同版本的兼容问题. 版权声明:本文为博主原创文章,未经博主允许不得转载. error: No resource identifier found for attribute 'format24Hour'

error: No resource identifier found for attribute ‘backIcon’ in package

异常提示: 今天我新创建了一个自定义控件,我为他定义了一个属性为backIcon,但是当我在xml设置这个属性之后,xml布局界面提示以下错误: 错误原因: 在网上查找错误原因的时候,有文章说这是因为我的布局文件的命名空间没有添加有包名的那个命名空间,可是我检查布局文件完毕之后,发现我已经添加了,但是还是报这个异常错误,我的命名空间为:xmlns:myview="http://schemas.android.com/apk/res/com.example.zhufu.view";后来我

Android出错问题:AndroidManifest.xml:2: error: No resource identifier found for attribute &#39;installLocatio

出错点: AndroidManifest.xml: error: No resource identifier found for attribute 'installLocation' in package 'android' 解决方法: 这是因为所使用的android中不支持该属性(installLocation),删除      android:installLocation="auto"即可,或者选择别的版本的android. Android出错问题:AndroidManife

Android开发之自定义Dialog二次打开报错问题解决

之前自定义了一个AlertDialog对话框,第一次点击时正常,但第二次调用时会出现错误:java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. 关于这个错误纠结了我好久,在网上百度了也不少,但感觉解决效果都达不到自己想要的效果.网上的解释说是一个子视图指定了多个父视图.由此可以推断出,在第二

git push报错error: failed to push some refs to &#39;[email&#160;protected]:

$ git push -u origin master To [email protected]:xxx/xxx.git ! [rejected] master -> master (fetch first) error: failed to push some refs to '[email protected]:xxx/xxx.git' hint: Updates were rejected because the remote contains work that you do hint: