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

Java Development

Reply
Highlighted
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

picturescrollfield showing wrong index on selecting

Hi,

I have used picturescrollfield and the images are added dynamically. 

 

The issue I am facing is when I am trying to select an image and enter to other screen. When I scroll it,it scrolls fast and when I am getting the current index it always shows either the first or last.

 

Here is my code.

pictureScrollField = new PictureScrollField(imgwidth, imgheight){
protected boolean touchEvent(net.rim.device.api.ui.TouchEvent message) {
int eventCode = message.getEvent();
if(eventCode==net.rim.device.api.ui.TouchEvent.CLICK){
FieldChangeListener listener = getChangeListener();
if (null != listener)
listener.fieldChanged(this, 1);
return true;
}

return super.touchEvent(message);
};
};
// pictureScrollField.set

pictureScrollField.setData(entries, 0);
pictureScrollField.setHighlightStyle(HighlightStyle.ILLUMINATE_WITH_MAGNIFY_LENS);
pictureScrollField.setHighlightBorderColor(0x00810937);
pictureScrollField.setCenteredLens(true);
pictureScrollField.setImageDistance(50);
//pictureScrollField.set
pictureScrollField.setTextColor(0x00810937);

pictureScrollField.setBackground(BackgroundFactory.createSolidTransparentBackground(0x00ECE4D7, 0));

pictureScrollField.setLabelsVisible(true);
pictureScrollField.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
if (context == 1) {
Dialog.alert("click:" + ((PictureScrollField)field).getCurrentImageIndex());
}
}
});

 

 

Can anybody help?

 

 

Rujuta Trivedi
Developer
Posts: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: picturescrollfield showing wrong index on selecting

Not sure but in my code like this I added a check to make sure that the picturescrollfield was the one with focus before getting the index to make sure.

 

_pictureScrollField.isFocus()


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing