关 闭

新闻中心

EEPW首页 > 工控自动化 > 设计应用 > 使用J2ME技术实现手机触摸屏开发的方法

使用J2ME技术实现手机触摸屏开发的方法

作者:时间:2008-08-21来源:网络收藏

  在目录下的22wtklibdevicesDefaultColorPhoneDefaultColorPhone.properties的文件中有一行touch_screen=false,把它改成true。

  MIDP2.0对于方法有三个:

  1.poerDragged( x, y) 拖拽事件(暂时还没研究)

  2.pointerPressed(int x, int y) 按压

  3.pointerReleased(int x, int y) 触摸屏释放

  pointerPressed(int x, int y)当用户按下触摸屏的时候会自动调用这个方法x,y就是当前压下的坐标

  pointerReleased(int x, int y)和pointerPressed(int x, int y)类似相应触摸屏释放事件

  这里,我只是以相应左右软键及菜单事件处理为例:

  protected void pointerPressed(int x, int y) {

  switch (status) {

  case .S_MENU:

  int menuWidth = 90;

  int = 17;

  int = 16;

  int = 10;

  if (x menuWidth y >(

   - ( * + ))) {

  int menuIndex = (y - ( - (

   * + ))) / menuItemHeight;

  doMenuOK(menuIndex);

  }

  case .S_DRAW_DIBIAO_LIST:

  case .S_LOCAL_SEARCH_RESULT:

  case Consts.S_MAP_VIEW:

  // 左右软键40*20的区域

  if (x 40 y >( - 20)) {

  doCommandLeft();

  }

  if (x >(screenWidth - 40) y >(screenHeight - 20)) {

  doCommandRight();

  }

  break;

  }

  }



评论


相关推荐

技术专区

关闭