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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Developer
rnickel
Posts: 62
Registered: ‎10-29-2008
My Carrier: Rogers
Accepted Solution

Zebra stripes on listview?

How might one go about setting an alternating background colour on listview cells?

 

My goal is to use 100% QML to do this.

 

Thanks!

Please use plain text.
Developer
kylefowler
Posts: 479
Registered: ‎05-17-2009
My Carrier: ATT

Re: Zebra stripes on listview?

In a list item component

 

Container {
    id: myitem
    layout: DockLayout {
    }
    background: {
                if(myitem.ListItem.indexPath % 2 == 0) {
                    return Color.Black
                } else {
                    return Color.White
                }
            }
        }

 

Like all of my posts
Please use plain text.
Developer
rnickel
Posts: 62
Registered: ‎10-29-2008
My Carrier: Rogers

Re: Zebra stripes on listview?

Knew it had to be something easy.

 

Still wrapping my head around QML.

 

Thanks a lot!

Please use plain text.
Developer
peter9477
Posts: 5,633
Registered: ‎12-08-2010
My Carrier: none

Re: Zebra stripes on listview?

In some situations, you may want to use ListItem.indexInSection instead of indexPath. Both are documented in https://developer.blackberry.com/cascades/reference/bb__cascades__listview.html

Peter Hansen -- (PlayBook and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.