3

I create a custom control as a android library. Everything is OK when i use this control in android project if i declare and use it programmatically, but i can't use this on XML so i follow this tut Declaring a custom android UI element using XML. In the first step, I meet this error

ERROR: In <declare-styleable> myView, unable to find attribute a:gender
ERROR: In <declare-styleable> myView, unable to find attribute a:location
....

And also this on R.java file

Syntax error, insert "}" to complete ClassBody

this is my 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>

Am I missing something?. Waiting for your help. Thanks you!

Community
  • 1
  • 1
Wayne
  • 6,093
  • 10
  • 43
  • 65

1 Answers1

4

Answer for my own question. Just remove "a:" before attr name everything will be fine.

    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <declare-styleable name="myView">                    
            <attr name="location"/>
            <attr name="gender"/>        
        </declare-styleable>
    </resources>
Wayne
  • 6,093
  • 10
  • 43
  • 65
  • Thanks! it works for me too! But I'd like to insert mynamespace:myattribute.. seems impossible then, but looks like android is doing that, eg: Do you have any idea? I've tried inserting XMLNS but it doesn't work, not sure whether it's not suppose to work or I'm doing it wrongly – Zennichimaro Jun 19 '13 at 02:42