關(guān) 閉

新聞中心

EEPW首頁 > 工控自動化 > 設(shè)計(jì)應(yīng)用 > 使用J2ME技術(shù)實(shí)現(xiàn)手機(jī)觸摸屏開發(fā)的方法

使用J2ME技術(shù)實(shí)現(xiàn)手機(jī)觸摸屏開發(fā)的方法

作者: 時間:2008-08-21 來源:網(wǎng)絡(luò) 收藏

  在目錄下的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)當(dāng)用戶按下觸摸屏的時候會自動調(diào)用這個方法x,y就是當(dāng)前壓下的坐標(biāo)

  pointerReleased(int x, int y)和pointerPressed(int x, int y)類似相應(yīng)觸摸屏釋放事件

  這里,我只是以相應(yīng)左右軟鍵及菜單事件處理為例:

  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;

  }

  }



評論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉