我创建了一个自定义控件作为android库。当我在android项目中使用这个控件时,如果我声明并以编程方式使用它,一切都是可以的,但是我不能在XML上使用它,所以我遵循这个tut Declaring a custom android UI element using XML。在第一步中,我遇到以下错误
ERROR: In <declare-styleable> myView, unable to find attribute a:gender
ERROR: In <declare-styleable> myView, unable to find attribute a:location
....在R.java文件中也是如此
Syntax error, insert "}" to complete ClassBody这是我的values\attrs.xml on library
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name="myView">
<attr name="a:location"/>
<attr name="a:gender"/>
</declare-styleable>
</resources>我是不是遗漏了什么?。等待你的帮助。谢谢你!
发布于 2011-11-23 15:36:44
回答我自己的问题。只需在attr name之前去掉"a:“就可以了。
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name="myView">
<attr name="location"/>
<attr name="gender"/>
</declare-styleable>
</resources>https://stackoverflow.com/questions/8177205
复制相似问题