2011-11-03 100 views
2

我在Eclipse中的一個項目,我作爲一個庫使用(我出口它作爲一個罐子,並在項目的其他部分導入的jarAndroid的自定義視圖 - 自定義錯誤屬性

我想補充一個。自定義按鈕查看與方法啓用/禁用,將背景改爲一個,我想在佈局指定(XML)

我跟着this tutorial但是當我出口的APK我得到這個錯誤:

錯誤:未找到包'com.xxx.library'中屬性'disabledBG'的資源標識符

這是attrs.xml文件我在我的庫項目:

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

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

</resources> 

,然後在我的應用程序項目(com.xxx.app.yyy),我有這樣的佈局:

<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" /> 
[...] 

而且當我去/gen/com.symbios.library/R.javaR.attr.disabledBG

我做錯了什麼?我錯過了什麼嗎?

P.S.當我以庫的形式導出庫時,我包含了src,genres文件夾。

回答

2

你的項目配置似乎有問題。 如果您有機會鏈接到項目,則不應使用jar庫。

請看看這篇文章: click here

希望它可以幫助

+0

感謝您的回答。我只是做了你說什麼,仍然沒有工作..你認爲我的XML命名空間是錯誤的? xmlns:mylib =「http://schemas.android.com/apk/res/com.xxx.library」 – SERPRO

+0

是的!使用android代替: 'xmlns:android =「http://schemas.android.com/apk/res/com.xxx.library」' –

+0

這會弄亂其餘的佈局..我是正如我在教程 – SERPRO