【问题标题】:How can i target an individual item in a titanium alloy listview?如何定位钛合金列表视图中的单个项目?
【发布时间】:2014-12-22 13:36:29
【问题描述】:

在钛合金中,如何专门针对钛列表视图中的第一项(我只需要更改第一项的背景颜色)?

使用列表视图查看:

<ListView id="hm_channel_comments" defaultItemTemplate="hm_commentTemplate">
<ListSection name="hm_comments" id="hm_comments_section"/>

我尝试过的一些事情(总是返回“未定义”):

$.hm_channel_comments.Item[0].setBackgroundColor("blue"); //not working
$.hm_comments_section.itemIndex[0].setBackgroundColor("blue"); //not working
console.log($.hm_comments_section.itemIndex[0] + " $.hm_comments_section.itemIndex[0] "); not working
console.log($.hm_comments_section.item[0] + " $.hm_comments_section.item[0] ");

【问题讨论】:

    标签: listview titanium-alloy


    【解决方案1】:

    需要 (a) 获取特定 listsection 的 listItemObject 并 (b) 更新它。像这样(当您只想将 backgroundColor 更改为 listSection 第一项的海军蓝):

    groups.xml 包含一个 ID 为“myTeamSectionJoined”的列表部分。

    groups.js:

    function disableOwnBuddyTransfer(){
        var groupFounder = $.myTeamSectionJoined.getItemAt(0);
        console.log("groupFounder" + JSON.stringify(groupFounder));
        groupFounder.d_four.backgroundColor = "navy";
        $.myTeamSectionJoined.updateItemAt(0, groupFounder);
    }
    

    真正有用的信息在http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_ListView_Guide

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多