简体   繁体   中英

Change background color of list item in Listview Titanium SDK

I am using the last version of Titanium SDK. I want to change the background of item in listview but it seems impossible.

I tried to use:

var item = $.section.getItemAt(index);
item.properties.backgroundColor = "#696969";
$.section.updateItemAt(index, item);

But I get the error said that the backgroundColor undefined... I find a solution is that using a View with size of the list item and then set background color for this View to archive the same result. However, I can not find a way to access the view inside the list item.

Someone have done this please give me your opinion. Thanks. :)

I find out that I need to specific the properties element on the data item.

var item = {
            bind1: {
                text : value1
                },
            bind2: {
                text : value2
            },
            properties:{
                backgroundColor:"#aaaaaa"
            }
        };

Now the code:

var item = $.section.getItemAt(index);
item.properties.backgroundColor = "#696969";
$.section.updateItemAt(index, item);

works as expected.

:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM