0

最近我的 Android 工作区不再正确编译(未创建 R 文件)。在尝试了通常的清洁之后,我开始更深入地搜索。我发现,当我用 format="enum" 注释掉我的 attrs.xml 类型的可声明样式文件中的项目时,R 文件已构建,但在它们存在时不会(未注释掉)。您拥有声明枚举或其他东西的方式最近有变化吗?这里是项目的一部分

在职的

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

<declare-styleable name="SwipeListView">
    <attr name="swipeOpenOnLongPress" format="boolean" />
    <attr name="swipeAnimationTime" format="integer" />
    <attr name="swipeOffsetLeft" format="dimension" />
    <attr name="swipeOffsetRight" format="dimension" />
    <attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
    <attr name="swipeFrontView" format="reference" />
    <attr name="swipeBackView" format="reference" />
<!--         <attr name="swipeMode" format="enum"> -->
<!--             <enum name="none" value="0" /> -->
<!--             <enum name="both" value="1" /> -->
<!--             <enum name="right" value="2" /> -->
<!--             <enum name="left" value="3" /> -->
<!--         </attr> -->
<!--         <attr name="swipeActionLeft" format="enum"> -->
<!--             <enum name="reveal" value="0" /> -->
<!--             <enum name="dismiss" value="1" /> -->
<!--             <enum name="choice" value="2" /> -->
<!--         </attr> -->
<!--         <attr name="swipeActionRight" format="enum"> -->
<!--             <enum name="reveal" value="0" /> -->
<!--             <enum name="dismiss" value="1" /> -->
<!--             <enum name="choice" value="2" /> -->
<!--         </attr> -->
<!--         <attr name="swipeDrawableChecked" format="reference" /> -->
<!--         <attr name="swipeDrawableUnchecked" format="reference" /> -->
</declare-styleable>
</resources>

不工作

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

<declare-styleable name="SwipeListView">
    <attr name="swipeOpenOnLongPress" format="boolean" />
    <attr name="swipeAnimationTime" format="integer" />
    <attr name="swipeOffsetLeft" format="dimension" />
    <attr name="swipeOffsetRight" format="dimension" />
    <attr name="swipeCloseAllItemsWhenMoveList" format="boolean" />
    <attr name="swipeFrontView" format="reference" />
    <attr name="swipeBackView" format="reference" />
    <attr name="swipeMode" format="enum">
        <enum name="none" value="0" />
        <enum name="both" value="1" />
        <enum name="right" value="2" />
        <enum name="left" value="3" />
    </attr>
    <attr name="swipeActionLeft" format="enum">
        <enum name="reveal" value="0" />
        <enum name="dismiss" value="1" />
        <enum name="choice" value="2" />
    </attr>
    <attr name="swipeActionRight" format="enum">
        <enum name="reveal" value="0" />
        <enum name="dismiss" value="1" />
        <enum name="choice" value="2" />
    </attr>
    <attr name="swipeDrawableChecked" format="reference" />
    <attr name="swipeDrawableUnchecked" format="reference" />

</declare-styleable>

4

1 回答 1

0

您是否尝试在声明样式之外定义枚举,然后在声明样式中使用 attr 而没有任何格式

于 2013-08-31T20:25:59.457 回答