How to implement dragging in LWUIT?

334 views Asked by At

My LWUIT application has 3 Forms:

1) FormA 2) FormB 3) FormC

The current form being displayed on the screen is FormB.

Case 1:

If the user swipes his finger LEFT on his touch screen phone, I want LWUIT to capture that event and display FormC

Case2:

If the user swipes his finger RIGHT on his touch screen phone, I want LWUIT to capture that event and display FormA

How do I do this? I think it has to do something with drag event but not sure how to implement it.

Thanks.

3

There are 3 answers

2
Vijay YD On BEST ANSWER
just need to override pointerDragged method in form and get/cal its X,Y positions and display another form. 


new Form()
{

protected void pointerDragged(int x, int y) {
if(x,y....)
{
form3.show();

}else
{
from1.show();
}
super.pointerDragged(x,y);

}

};

here x,y can be calculated based on screen resolutions and components u have added to it.
2
Vijay YD On

instead of taking 3 forms use 3 containers under 1 form and setScrollableX(true) and add all components in appropriate containers.

0
Shai Almog On

Use the Tabs component with 3 Containers, it supports Swipe. You can set the Tabs themselves to be hidden.