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
Kaz32
Posts: 236
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: Telkomsel
Accepted Solution

How to set background / highlight item on listView when use multi select

Hi I'm used multi select on list view, the problem is when selected the item not change background (I think default will change to lightblue)

 

Maybe because I'm not  use StandardListItem on itemList, I'm use own container for itemList.

 

How to set color on highlighted item on multi select listView?

 

Thanks

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

Re: How to set background / highlight item on listView when use multi select

In ListItemListener subclass:

 

1) Create the background manually, for example:

 

        background_ = Container::create()
.visible(false) .background(Color::Blue) .layout(DockLayout::create()) .horizontal(HorizontalAlignment::Fill) .vertical(VerticalAlignment::Fill)

 

2) Implement ListItemListener methods:

void MyListItem::select(bool select)
{
        background_->setVisible(select);
}

void MyListItem::activate(bool activate)
{
        select(activate);
}

void MyListItem::reset(bool selected, bool activated)
{
        Q_UNUSED(activated);
        select(selected);
}

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
Kaz32
Posts: 236
Registered: ‎11-24-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: Telkomsel

Re: How to set background / highlight item on listView when use multi select

I use background property on my custom itemList Container :

 

Container {

id: listItemContainer

background: listItemContainer.ListItem.selected ? Color.create("#18AFE2") : Color.create("#018AFE2")

...

}

 

Please use plain text.
Trusted Contributor
becker666
Posts: 123
Registered: ‎04-12-2010
My Device: Storm
My Carrier: Verizon

Re: How to set background / highlight item on listView when use multi select

[ Edited ]

The background tag with ListItem.selected works fine ... maybe I'm pushing this I wanted  to make it a bit fancier iPhone like by having a little checkbox image in each row which would be visible/invisible  according to ListItem.selected value , but it is not taking it is that allowed???? Tried this in my LisItemComponent

 

....

Imageview{

    id:marker

    imageSource: ListItem.selected?<path to pic>:<path to pic2>    // no go

    visible: ListItem.selected   // didn't go either

}

....

 

Managed by adding an image to the Model but that seemed too tweaky

Please use plain text.
BlackBerry Development Advisor
sabdelsayed
Posts: 249
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: How to set background / highlight item on listView when use multi select

Hi Kaz32, starting the 10.2 SDK you can use the new CustomListItem API for your list items. The API has a property called highlightAppearance, which allows you to specify a highlighting behavior (full or frame) for your list items on active, select and longpress.

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Please use plain text.