我遵循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?
感谢您的回答。你能看看我的编辑吗? –