如何在LWUIT中实现拖动?

时间:2012-04-19 02:48:36

标签: lwuit lwuit-form lwuit-container

我的LWUIT应用程序有3种形式:

1)FormA 2)FormB 3)FormC

屏幕上显示的当前表格是FormB。

案例1:

如果用户在他的触摸屏手机上左手滑动手指,我希望LWUIT捕获它 事件并显示FormC

情况2:

如果用户在他的触摸屏手机上右手滑动手指,我希望LWUIT捕获它 事件并显示FormA

我该怎么做?我认为它必须对拖动事件做一些事情,但不确定如何实现它。

感谢。

3 个答案:

答案 0 :(得分:1)

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.

答案 1 :(得分:1)

使用带有3个容器的标签组件,它支持滑动。您可以将标签本身设置为隐藏。

答案 2 :(得分:0)

而不是采用3个表单,使用1个表单下的3个容器和setScrollableX(true),并将所有组件添加到适当的容器中。