更改Listview Titanium SDK中列表项的背景颜色

Pau*_*aul 1 android titanium

我正在使用最新版本的Titanium SDK.我想在listview中更改项目的背景但似乎不可能.

我试着用:

var item = $.section.getItemAt(index);
item.properties.backgroundColor = "#696969";
$.section.updateItemAt(index, item);
Run Code Online (Sandbox Code Playgroud)

但我得到错误说backgroundColor未定义...我发现一个解决方案是使用View列表项的大小,然后为此View设置背景颜色以存档相同的结果.但是,我找不到一种方法来访问列表项中的视图.

有人这样做请给我你的意见.谢谢.:)

Pau*_*aul 6

我发现我需要在数据项上具体指定properties元素.

var item = {
            bind1: {
                text : value1
                },
            bind2: {
                text : value2
            },
            properties:{
                backgroundColor:"#aaaaaa"
            }
        };
Run Code Online (Sandbox Code Playgroud)

现在的代码:

var item = $.section.getItemAt(index);
item.properties.backgroundColor = "#696969";
$.section.updateItemAt(index, item);
Run Code Online (Sandbox Code Playgroud)

按预期工作.

:)