SERPRO
SERPRO

Reputation: 10067

Android custom view - Error with custom attributes

I have a project in Eclipse that I use as a library (I export it as a jar and import the jar in the rest of the projects.

I want to add a custom Button View with the methods enabled/disabled that will change the background to one that I want to specify in the layout (XML)

I followed this tutorial but when I export the apk I got this error:

error: No resource identifier found for attribute 'disabledBG' in package 'com.xxx.library'

this is the attrs.xml file I have in my library project:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <declare-styleable name="MyButton">
        <attr format="integer" name="disabledBG" />
    </declare-styleable>

</resources>

and then on my application project (com.xxx.app.yyy), I have this in the layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:mylib="http://schemas.android.com/apk/res/com.xxx.library"
[...]
    <com.xxx.library.View.MyButton
                android:id="@+id/menuMap"
                style="@style/SHGreenButtons"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_marginBottom="12dp"
                android:clickable="true"
                mylib:disabledBG="@drawable/disabled_buttons"
                android:onClick="goMap"
                android:text="@string/menu_map" />
[...]

Also when I go to /gen/com.symbios.library/R.java there's R.attr.disabledBG

What am I doing wrong? Am I missing something?

P.S. When I exported the library as jar, I included the src, gen and res folders.

Upvotes: 2

Views: 1006

Answers (1)

Mathieu de Brito
Mathieu de Brito

Reputation: 2696

It seems there is something wrong with your project configuration. You shouldn't use a jar lib if you have the opportunity to link to the project.

Please take a look at this article : click here

Hope it helps

Upvotes: 1

Related Questions