【问题标题】:Appcelerator studio change listitem backgroundcolor on clickAppcelerator Studio 在点击时更改列表项背景颜色
【发布时间】:2015-06-24 22:02:50
【问题描述】:

我在这个问题上需要帮助,我在 appcelerator studio 上有一个这样的列表视图:

<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>

本节更新了网络服务调用*,所以在我的 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 的文档中,他们“更改”了一些属性,例如完整行的背景颜色,但是,这样会提高属性错误不是对象,有帮助吗?

【问题讨论】:

    标签: android ios titanium appcelerator appcelerator-mobile


    【解决方案1】:

    好的,我找到了一种方法,我真的希望这会有所帮助,首先我在视图中放置了一个包含行的所有内容的视图,并将其放置为这样的 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 控制器中使用它的 bindId 属性更改视图的背景颜色,如下所示:

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

    仅此而已

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-24
      • 2019-05-09
      • 1970-01-01
      相关资源
      最近更新 更多