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
Regular Contributor
_NishantShah
Posts: 76
Registered: ‎07-31-2012
My Device: Blackberry
My Carrier: Vodafone
Accepted Solution

Binding Image View of a List View with QImage & PixelBuffer Data

Hi,

 

I need to develop a photo gallary like application. I need to load different images in a grid list view.

 

I can paint images on a single ImageView using PixelBufferData.

 

PixelBufferData pixelBuffer = PixelBufferData(PixelBufferData::RGBX, width, height, width, qimage.bits());

    Image image = Image(pixelBuffer);
    imageView->setImage(image);

 

Now I need to bind this with a grid list view. How to get paint ListItem Specific Image view.

 

ListView {
id: albumsListView
objectName: "albumsListView"
layout: GridListLayout {
columnCount: 5
 }

 

dataModel: XmlDataModel {
source: "models/album.xml"
}

listItemComponents: [
ListItemComponent {
type: "album"
MyListItem {
}
}
]

 

MyListItem is a Custom component:

 

Container {
 id: myItemContainer
layout: DockLayout {
}
Container {
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
}
layout: DockLayout {
}
ImageView {
id: coverImageView
objectName: "coverImageView"
imageSource: ListItemData.coverImage
preferredWidth: 250
preferredHeight: 250
}
Container {
background: Color.Black
opacity: 0.7
layout: DockLayout {
}
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Bottom
}
Label {
text: ListItemData.name
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Bottom
}
textStyle {
base: SystemDefaults.TextStyles.BodyText
fontWeight: FontWeight.Bold
color: Color.White
}
}
}
}
}

 

I tried calling method in onCreationComplete of imageView & onImageSourceChanged of ImageView but didn't work.

Please use plain text.
Regular Contributor
_NishantShah
Posts: 76
Registered: ‎07-31-2012
My Device: Blackberry
My Carrier: Vodafone

Re: Binding Image View of a List View with QImage & PixelBuffer Data

Well I did manage to find the solution.

 

I just used custom ListItemManager & ListItemListener to update image view in list & it worked fine.

 

You can refer below mentioned links for more info. Documentaion is quite good. Its very easy to understand & implement.

 

https://developer.blackberry.com/cascades/reference/bb__cascades__listitemmanager.html

https://developer.blackberry.com/cascades/reference/bb__cascades__listitemlistener.html

 

Sorry to bother you all.

 

Nishant Shah

Please use plain text.