1

在不支持遍历的手机中如何处理J2ME的CustomItem中的遍历?

我正在使用 J2ME - MIDP 2.0 做一个移动应用程序。在我的应用程序中,我使用javax.microedition.lcdui.CustomItem. 我也实现了这个traverse方法。但有些手机不支持遍历。如何在不支持遍历的手机中实现遍历过程?

4

1 回答 1

1

我得到了问题的解决方案。

首先我们通过类“javax.microedition.lcdui.CustomItem”的方法“getInteractionModes()”发现设备是否支持遍历。由此我们得到遍历支持与否。

如果不支持遍历,则为其添加一个命令按钮,然后在按钮单击事件处理中实现遍历操作( public void commandAction(Command c, Item item) )。

查找设备是否支持遍历显示在以下代码片段中

int supported_interaction_modes=this.getInteractionModes();
boolean horizontal_interaction,vertical_interaction;

if((supported_interaction_modes&CustomItem.TRAVERSE_HORIZONTAL)!=0)
  horizontal_interaction=true;
else
  horizontal_interaction=false;

if((supported_interaction_modes&CustomItem.TRAVERSE_VERTICAL)!=0)
  vertical_interaction=true;
else
  vertical_interaction=false;

在上面的代码片段中,“this”指的是 CustomItem 的子类 (javax.microedition.lcdui.CustomItem),它是用于 CustomItem 操作的用户定义类。

于 2010-12-14T12:34:43.620 回答