關 閉

新聞中心

EEPW首頁 > 工控自動化 > 設計應用 > 使用J2ME技術實現手機觸摸屏開發(fā)的方法

使用J2ME技術實現手機觸摸屏開發(fā)的方法

作者: 時間: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的區(qū)域

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

  doCommandLeft();

  }

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

  doCommandRight();

  }

  break;

  }

  }



評論


相關推薦

技術專區(qū)

關閉