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
New Developer
Posts: 40
Registered: ‎12-04-2009
My Device: Storm 9530
Accepted Solution

How to implement image swipe for Blackberry 5.0 and later OS devices?

Hi All,
I need to develop swipe functionality in a application. For that, i have added five bitmapfield in five different verticalfield manager and these five verticalfiled manager have been added in a horizontalfield manager with Horizonatal Scroll property. And try to implement swipe functionality using Touch Event. Below code is working for Blackberry 5.0 OS devices but Its not working in Blackberry 6.0 and later OS devices.

 

protected boolean touchEvent(TouchEvent message)
{

try{
int x = message.getX(1);
int y = message.getY(1);

int eventCode = message.getEvent();
if(eventCode == TouchEvent.DOWN)
{
Dx=x;
Dy=y;
}
else if(eventCode == TouchEvent.UP)
{

Ux=x;
Uy=y;

disX= Dx-Ux;
disY= Dy-Uy;

if(disX > (Display.getWidth()/3) && this.index<6)
{

if(this.index<5)
this.index++;
vfmImage[this.index].setFocus();
System.out.println("disX :"+disX +" differnt :"+(Display.getWidth()/3)+" Index :"+this.index);

}

else if(disX < Display.getWidth() -(Display.getWidth() + Display.getWidth()/3) && index>0)
{

if(this.index>0)
this.index--;
vfmImage[this.index].setFocus();
System.out.println("disX :"+disX +"differnt :"+(Display.getWidth() -(Display.getWidth() + Display.getWidth()/3))+" Index :"+this.index);

}
else
{
if(index==0)
{
vfmImage[1].setFocus();
}
else
{
vfmImage[this.index-1].setFocus();
}

vfmImage[this.index].setFocus();

}

}

}
catch (Exception e)
{
Dialog.alert("catch");
e.printStackTrace();
}
return super.touchEvent(message);
}


Thanks
Devang

 

Super Contributor
Posts: 278
Registered: ‎11-04-2010
My Device: 4.5 and above
My Carrier: none

Re: How to implement image swipe for Blackberry 5.0 and later OS devices?

New Developer
Posts: 40
Registered: ‎12-04-2009
My Device: Storm 9530

Re: How to implement image swipe for Blackberry 5.0 and later OS devices?

Hi pp,

Thanks for your Reply.

I have prepared demo of it but its left top margin automatically. Have you any idea about how can i remove that margin? Please find attached screen shot of it.

 

 

 

Thanks 

Devang