我遵循this指南爲我的應用製作自定義ListView
。本教程使用名爲ottasee的名稱空間,應將其定義爲元素內的xml名稱空間。因此,這裏是我的一些代碼:自定義ListView - 如何將attrs.xml設置爲命名空間
<com.my.app.Layout.CustomListView
xmlns:ottasee="what_should_i_put_here?"
android:id="@+id/lastCases"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@null"
android:scrollbars="none"
ottasee:dropShadowBottom="true"
ottasee:dropshadowrightsrc="@drawable/drop_shadow"
/>
我可以看到屬性ottasee:dropShadowBottom
和ottasee:dropshadowrightsrc
是在價值觀夾我的attrs.xml
一部分。就像這樣:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name="DropShadowListView">
<attr format="boolean" name="dropShadowLeft"></attr>
<attr format="reference" name="dropShadowLeftSrc"></attr>
<attr format="boolean" name="dropShadowRight"></attr>
<attr format="reference" name="dropShadowRightSrc"></attr>
<attr format="boolean" name="dropShadowTop"></attr>
<attr format="reference" name="dropShadowTopSrc"></attr>
<attr format="boolean" name="dropShadowBottom"></attr>
<attr format="reference" name="dropShadowBottomSrc"></attr>
</declare-styleable>
</resources>
我應該如何才能抓住從attrs.xml
文件的屬性定義爲ListView
XML命名空間?
謝謝!
編輯
我CustomListView是包com.my.app.Layout
下,我試圖通過這種方式聲明NS:xmlns:ottasee="http://schemas.android.com/apk/res/com.my.app.Layout
但我只在我的xml文件得到一個錯誤:
Multiple annotations found at this line:
- error: No resource identifier found for attribute 'dropShadowBottom' in package
'com.my.app.Layout'
- error: No resource identifier found for attribute 'dropshadowrightsrc' in package
'com.my.app.Layout'
我該如何完成設置正確的ns?
感謝您的回答。你能看看我的編輯嗎? –