Is it possible to change any specific list item's view without listening to item tap event?


#1

I have a list view , which will not respond to tap event , but I want to make change to specific item’s view style when the observable array has been updated , for instance , to remind the user by changing the specific item’s background when the binded data item has changed , is it possible ?
Thanks , I have been looking into official API document , found no clue ~


#2

anyone please ? really got stuck here


#4

Hi,

If you change a property on a specific item in your model,

var item:Item = this.items.getItem( yourItemToChangeIndex );
item.bgColor = '0x333333';

the corresponding view in your listView should be changed :

<ListView items="{{ items }}"/>
    <ListView.itemTemplates>
        <GridLayout backgroundColor="{{ bgColor }}"/>
    </ListView.itemTemplates>
</ListView>

You can also want to change a boolean property :

<ListView items="{{ items }}"/>
    <ListView.itemTemplates>
        <GridLayout backgroundColor="{{ isUserOnline ? '0X333333' : '0x000000' }}"/>
    </ListView.itemTemplates>
</ListView>

or a class to apply :

<ListView items="{{ items }}"/>
    <ListView.itemTemplates>
        <GridLayout class="{{ isUserOnline ? 'myStyleClassTrue' : 'myStyleClassFlase' }}"/>
    </ListView.itemTemplates>
</ListView>

Hope this help.


#5

thank you , very clever idea ! it indeed helps , but i wanna go further , after change/flash the background color , i also wanna remove the item view by animation , any idea ?


#6

You could use the awesome RadListView on which you can enable item animations (fade, scale, slide) on itemInsertAnimation and itemDeleteAnimation events.

You can read this : RadListView: Item Animations

Samples here : Item animations samples


#7

thank you , your answers have been most helpful and informative !