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
Highlighted
Developer
Posts: 148
Registered: ‎01-08-2013
My Device: 9860
My Carrier: Airtel
Accepted Solution

Change the image click on Listview Item

Hi All,

    

 I want to change the image of listview item. When I touch on the list item the image is changed and after leave the touch event the changed image remains same. Please solve my problem.

 

Thanks & regards

       Sanjit

Developer
Posts: 109
Registered: ‎08-23-2012
My Device: Blackberry Z10
My Carrier: TATA DOCOMO

Re: Change the image click on Listview Item

You can use the below functions to fulfill your need

 

ListItem.onActivationChanged: {
setHighlight(ListItem.active);
}
ListItem.onSelectionChanged: {
setHighlight(ListItem.selected);
}

 

function setHighlight(highlighted) {
if (highlighted) {
highlightContainer.background = Color.create("#EEEDED");
} else {
highlightContainer.background = Color.Transparent;
}
}

 

May be this will solve your problem.

Dharmender Singh
Developer
Posts: 148
Registered: ‎01-08-2013
My Device: 9860
My Carrier: Airtel

Re: Change the image click on Listview Item

But when touch event is removed the color is changed. I want the changed color when touchevent occur and removed.

Developer
Posts: 109
Registered: ‎08-23-2012
My Device: Blackberry Z10
My Carrier: TATA DOCOMO

Re: Change the image click on Listview Item

remove the else part of the setHighlight function. It means that when you will leave the touch, the else part will not execute.

Press like if this solve your problem.
Dharmender Singh