Just don't re-declare the format in the second one.  Also, if this is a
color, don't you want the format to be "color"?  As it is now, when you
write a color of the form "0xfff" you will not get the right integer value
for an aarrggbb color.

Oh and I am almost positive the framework already has a color attribute
defines, so you could just use that.

On Fri, Apr 17, 2009 at 7:48 AM, Vlemmix <e...@vlemmix.net> wrote:

>
> Hello all,
>
> I'm introducing multiple custom widgets for my application, extending
> View. These widgets (LineGraph and DotMatrix) include various
> attributes that can be set via the layout-xml. How can I have multiple
> widgets using attributes with the same name. For instance, 2
> attributes both having color as an attribute that can be set via the
> layout XML?
>
> main.xml snippet:
>
> XML:
> xmlns:app="http://schemas.android.com/apk/res/
> net.vlemmix.android.widgetdemos"
> <net.vlemmix.android.widget.DotMatrix
>          android:id="@+id/dotmatrix1"
>          android:layout_width="wrap_content"
>          android:layout_height="wrap_content"
>          app:color="0xFFF" />
>
>
> attrs.xml snippet:
> XML:
> <?xml version="1.0" encoding="UTF-8"?>
> <resources>
> <declare-styleable
>          name="DotMatrix">
>          <attr
>               name="color"
>               format="integer" />
>     </declare-styleable>
> </resources>
>
>
> When I want to add the info for my LineGraph in attrs.xml, Eclipse
> starts to whine: "ERROR Attribute "color" has already been defined"
> XML:
> <?xml version="1.0" encoding="UTF-8"?>
> <resources>
> <declare-styleable
>          name="DotMatrix">
>          <attr
>               name="color"
>               format="integer" />
>     </declare-styleable>
> <declare-styleable
>          name="LineGraph">
>          <attr
>               name="color"
>               format="integer" />
>     </declare-styleable>
> </resources>
>
>
> Is it not possible to have a DotMatix resource with a color attribute,
> and a LineGraph resource with a color attribute?
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to