点击Appcelerator studio更改列表项背景颜色



我需要这个主题的帮助,我在appcelerator工作室上有一个列表视图,如下所示:

<ListView id="lvPropuestas" defaultItemTemplate="plantilla">
        <Templates>
            <ItemTemplate name="plantilla">                                 
                    <Label bindId="bindGarantia" class="columnG columnContentStyle"></Label>
                    <Label bindId="bindPropuesta" class="columnProp columnContentStyle"></Label>
                    <Label bindId="bindMonto" class="columnM columnContentStyle"></Label>
                    <Label bindId="bindPrima" class="columnPrim columnContentStyle"></Label>
                    <Button bindId="btnNavega" class="btnTabla" onClick="DetallePropuesta">></Button>
                    <!-- 
                    -->                 
            </ItemTemplate>
        </Templates>
        <HeaderView>
            <View backgroundColor="#E2DBD3" height="35dip">
                <Label id="headerG" class="titleStyle">GARANTIA</Label>
                <Label id="headerProp" class="titleStyle">PROPUESTAS</Label>
                <!--
                -->
                <Label id="headerM" class="titleStyle">MONTO</Label>
                <Label id="headerPrim"  class="titleStyle">PRIMA</Label>
            </View>
        </HeaderView>
        <ListSection>
        </ListSection>
    </ListView>

这一部分是在web服务调用*上更新的,所以在我的js中,我声明了一个事件监听器,如下所示:

$.lvPropuestas.addEventListener('itemclick',seleccionFila);

最后,我的函数是这样的:

function seleccionFila(e){
    var item = e.section.getItemAt(e.itemIndex);
    item.properties.color ='#33CCCC';
    e.section.updateItemAt(e.itemIndex, item); }

我试图更改列表项的背景色,但在单击的那一刻,我捕捉到了该项,但在appcelerator的文档中,他们"更改"了一些属性,比如整行的背景色。但是,这样会引发属性错误。属性不是对象,有什么帮助吗?

好的,我找到了一种方法来做这件事,我真的希望这会有所帮助,首先我在视图中放了一个包含该行所有内容的视图,并把它放在一个bindId中,如下所示:

<View bindId="bindView">
    <Label bindId="bindGarantia" class="columnG columnContentStyle"></Label>
    <Label bindId="bindPropuesta" class="columnProp columnContentStyle"></Label>
    <Label bindId="bindMonto" class="columnM columnContentStyle"></Label>
    <Label bindId="bindPrima" class="columnPrim columnContentStyle"></Label>
    <Button bindId="btnNavega" class="btnTabla" onClick="DetallePropuesta">></Button>
    <!-- 
    --> 
</View>

然后在js控制器中,只需更改视图的backgroundColor及其bindId属性,如下所示:

function seleccionFila(e) {
    var item = e.section.getItemAt(e.itemIndex);
    item.bindView.backgroundColor = "#efefef";
    e.section.updateItemAt(e.itemIndex, item);
}

这就是

最新更新