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
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10

Changing the colour of a List Item?

Is it possible to change the colour of a List Item?

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Changing the colour of a List Item?

[ Edited ]

Yes, by creating a custom ListItemComponent. For example:

http://supportforums.blackberry.com/t5/Native-Development/How-to-implement-alternate-row-coloring-on...

 

 If you need a StandardListItem, this will likely also work, but I haven't tried this:

 

ListItemComponent {
  Container {
    background: Color.red
    StandardListItem {
      ...
    }
  }
}

 

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10

Re: Changing the colour of a List Item?

Thanks but the colour doesn't appear.

 

What about the colour of the text?

Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Changing the colour of a List Item?

It should have done, I use the same thing in my app although I take in to account the theme and it definately works...

 

ListItemComponent {

    id: textItem

    type: "textItem"

    Container {
        layout: StackLayout {
            orientation: LayoutOrientation.LeftToRight
        }

        background: (ListItem.indexInSection % 2) ? (Application.themeSupport.theme.colorTheme.style == VisualStyle.Bright ? Color.LightGray : Color.DarkGray) : Color.Transparent

   [ ... ]

}

 Text colour can also be changed...

 

http://developer.blackberry.com/native/documentation/cascades/ui/text/styles.html


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Changing the colour of a List Item?

[ Edited ]

Use Red instead of red, I'm surprised you didn't get an error for this if you typed it in as Zmey wrote?

 

Momentics would have also given you a 'Unknown member' warning in the shape of an i to the left of the line. 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10

Re: Changing the colour of a List Item?

Does that need to be inside a List View?

Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Changing the colour of a List Item?

It does yes.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
macaronlover
Posts: 101
Registered: ‎01-06-2014
My Device: Q10

Re: Changing the colour of a List Item?

OK what about just changing the foreground colour of a list item?

Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Changing the colour of a List Item?

What do you mean by foreground colour?

 

You are in control of what is put on the ListItem, each control you place there has different properties that can be changed.

 

If you place a container on the back you can use the background property to change the colour.

 

You can also mix this with transparancy if you want a shade over whatever Labels or Controls you are using.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
greenmr
Posts: 882
Registered: ‎03-20-2013
My Device: Red LE Developer Z10

Re: Changing the colour of a List Item?

Near-identical thread here. Forum search is your friend.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.
Please use plain text.