Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
Accepted Solution

How to implement alternate row coloring on a ListView?

I am trying to change the ListItem background color based on the even or odd number of the current row. Is it possible on Cascade programming? Thank you




p(^_^)q
Good good study, day day up
Developer
strobejb
Posts: 282
Registered: ‎10-15-2012
My Device: bb10 developer

Re: How to implement alternate row coloring on a ListView?

There's no direct way but:

You could probably inspect the indexPath in the ListItemComponent (i.e. ListItem.indexInSection) and use this value (modulo 2) to determine if you have an odd or even row

i.e.

ListItemComponent {
Container {
background: ListItem.indexInSection % 2 ? Color.red : Color.blue
}
}

maybe.. i didn't test the above so you might need to play around with it
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: How to implement alternate row coloring on a ListView?

Cool. I got it. Thank you.




p(^_^)q
Good good study, day day up