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
rnickel
Posts: 62
Registered: ‎10-29-2008
My Device: 9800
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: 526
Registered: ‎05-17-2009
My Device: 9900
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 Device: 9800
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: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
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 -- (BB10 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.