2012-05-18 42 views
1

我正在使用此小工具https://github.com/erikwt/PullToRefresh-ListView並希望進行一些更改。我已經定義了attrs.xml,以便能夠從XML定義中控制文本的顏色等。但是我的自定義屬性沒有被識別(錯誤是:'eu.erikw'包中的屬性'ptrContainerBackground'找不到資源標識符)。 我已經使用了我在其他庫項目中定義的自定義視圖,並且目前爲止一切運行良好。你能幫忙解決問題嗎?在android佈局文件中無法識別自定義XML屬性

這裏是我的attrs.xml:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<declare-styleable name="eu.erikw.PullToRefreshListView"> 
    <attr name="ptrContainerBackground" format="integer"/> 
    <attr name="ptrArrow" format="integer"/> 
    <attr name="ptrTextColor" format="integer"/> 
    <attr name="ptrTextSize" format="integer"/> 
</declare-styleable>  
</resources> 

這裏是在佈局文件中的視圖定義:

<eu.erikw.PullToRefreshListView xmlns:ptr="http://schemas.android.com/apk/res/eu.erikw" 
     android:id="@+id/lv_transactionsList" 
     ptr:ptrTextColor="@color/text_white_color" 
     ptr:ptrContainerBackground="@color/text_white_color" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:divider="@drawable/transactions_list_divider" 
     android:dividerHeight="1dip" 
     android:cacheColorHint="@color/stations_finder_item_bg"> 
</eu.erikw.PullToRefreshListView> 

回答

5

1)儘量清理項目,並重新構建,和/或

2)檢查eu.erikw是否處於

右側包周

的xmlns:PTR = 「http://schemas.android.com/apk/res/eu.erikw」

這應該是

的xmlns:PTR =「HTTP://模式.android.com/APK/RES/your_package_name

其中your_package_name在您AndroidManifest.xml

3)不要使用點(收費)

012應用程序包中定義

聲明,設置樣式名稱= 「eu.erikw.PullToRefreshListView」>

,因爲這將使得很難檢索Java代碼ATTRS。

相關問題