Android 在values\attrs.xml中声明属性时出错
我创建了一个自定义控件作为android库。当我在android项目中使用这个控件时,如果我以编程的方式声明并使用它,一切都是好的,但我不能在XML上使用它,所以我遵循这个tut。在第一步中,我遇到了这个错误Android 在values\attrs.xml中声明属性时出错,android,custom-controls,Android,Custom Controls,我创建了一个自定义控件作为android库。当我在android项目中使用这个控件时,如果我以编程的方式声明并使用它,一切都是好的,但我不能在XML上使用它,所以我遵循这个tut。在第一步中,我遇到了这个错误 ERROR: In <declare-styleable> myView, unable to find attribute a:gender ERROR: In <declare-styleable> myView, unable to find attribut
ERROR: In <declare-styleable> myView, unable to find attribute a:gender
ERROR: In <declare-styleable> myView, unable to find attribute a:location
....
这是库上的my values\attrs.xml
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name="myView">
<attr name="a:location"/>
<attr name="a:gender"/>
</declare-styleable>
</resources>
我错过什么了吗?。等待你的帮助。谢谢你 回答我自己的问题。只需删除“a:”在attr name之前,一切都会好起来的
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name="myView">
<attr name="location"/>
<attr name="gender"/>
</declare-styleable>
</resources>
谢谢!它对我也有用!但是我想插入mynamespace:myattribute。。看起来不可能,但看起来android正在这么做,例如:你有什么想法吗?我尝试过插入XMLNS,但它不起作用,不确定它是不起作用还是我做得不对
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name="myView">
<attr name="location"/>
<attr name="gender"/>
</declare-styleable>
</resources>