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

Changing the colour of a List Item?

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

Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

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

Re: Changing the colour of a List Item?

Thanks but the colour doesn't appear.

 

What about the colour of the text?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

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.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

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.
Developer
Posts: 101
Registered: ‎01-06-2014
My Device: Q10
My Carrier: EE

Re: Changing the colour of a List Item?

Does that need to be inside a List View?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

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.
Developer
Posts: 101
Registered: ‎01-06-2014
My Device: Q10
My Carrier: EE

Re: Changing the colour of a List Item?

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

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

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.
Developer
Posts: 1,021
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

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.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.