我如何定位钛合金列表视图中的单个项目?

时间:2014-12-22 13:36:29

标签: listview titanium-alloy

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

使用列表视图查看:

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

我尝试过的一些事情(总是返回&#34;未定义&#34;):

$.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] ");

1 个答案:

答案 0 :(得分:0)

需要(a)获取特定列表部分的listItemObject并(b)更新它。这样的事情(当你只想将backgroundColor更改为listSection的第一项的海军时):

groups.xml包含一个id为#34; myTeamSectionJoined&#34;的列表部分。

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