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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 16
Registered: ‎05-26-2013
My Device: Z10
My Carrier: UAE DU
Accepted Solution

Changing background color for a selected item in a ListView?

Hi,

 

 Any idea how to change tbackground color of a ListView selected item from blue to a another color?

 

 I tried wrapping the ListView in a Container then changing the background color of the container, but that did not work. And neither the ListView nor the ListItemComponent takes a background attribute.

 

 

Thanks,

Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: Changing background color for a selected item in a ListView?

Ah, I did that last night. 
So, in the container for StandardItem, add this line:

 background: ListItem.selected || ListItem.active ? Color.create("#4D9EC9") : Color.Transparent

 and onTriggerred signal, add couple lines:

// for highlighting
listView.select(indexPath, true);
                           
// for clearing highlight
listView.clearSelection();

PS: listView is the id of the ListView

ListView {
    id: listView
....

 

 

Developer
Posts: 1,748
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Changing background color for a selected item in a ListView?

hint: Color.create is expensive

 

so its recommended to it this way

Page {
id: myPage
property variant selectionColor: Color.create("#4D9EC9")

and then

 

background: ListItem.selected || ListItem.active ? myPage.selectionColor : Color.Transparent
-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Highlighted
Contributor
Posts: 16
Registered: ‎05-26-2013
My Device: Z10
My Carrier: UAE DU

Re: Changing background color for a selected item in a ListView?

Thank you all, the selection color is now changed.

 

Another quick one, how now to change the grouping line color. I have my DataGroupModel (inside the ListView) doing grouping based on the first charcter of the contact, so in when the page is rendered in the ListView contacts are grouped properly, but with the default line separator in Blue, I also would like to change this color as well, how possible?

 

Thanks again,

Developer
Posts: 1,748
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Changing background color for a selected item in a ListView?

you should open a new thread for a new question

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Contributor
Posts: 16
Registered: ‎05-26-2013
My Device: Z10
My Carrier: UAE DU

Re: Changing background color for a selected item in a ListView?

Sure, will do that. 

 

Thanks,