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

發(fā)布時(shí)間:2010-12-9 17:39    發(fā)布者:conniede
關(guān)鍵詞: J2ME , 觸摸屏 , 手機
在WTK目錄下的WTK22wtklibdevicesDefaultColorPhoneDefaultColorPhone.properties的文件中有一行touch_screen=false,把它改成true。

MIDP2.0對于觸摸屏方法有三個(gè):

1.pointerDragged(int x, int y) 觸摸屏拖拽事件(暫時(shí)還沒(méi)研究)

2.pointerPressed(int x, int y) 觸摸屏按壓

3.pointerReleased(int x, int y) 觸摸屏釋放

pointerPressed(int x, int y)當用戶(hù)按下觸摸屏的時(shí)候會(huì )自動(dòng)調用這個(gè)方法x,y就是當前壓下的坐標

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

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

protected void pointerPressed(int x, int y) {

switch (status) {

case Consts.S_MENU:

int menuWidth = 90;

int menuItemHeight = 17;

int menuBarHeight = 16;

int menuNum = 10;

if (x (

screenHeight - (menuItemHeight * menuNum + menuBarHeight))) {
int menuIndex = (y - (screenHeight - (

menuItemHeight * menuNum + menuBarHeight))) / menuItemHeight;
doMenuOK(menuIndex);

}

case Consts.S_DRAW_DIBIAO_LIST:

case Consts.S_LOCAL_SEARCH_RESULT:

case Consts.S_MAP_VIEW:

// 左右軟鍵40*20的區域

if (x <40 &&y >(screenHeight - 20)) {

doCommandLeft();

}

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

doCommandRight();

}

break;

}

}
本文地址:http://selenalain.com/thread-45518-1-1.html     【打印本頁(yè)】

本站部分文章為轉載或網(wǎng)友發(fā)布,目的在于傳遞和分享信息,并不代表本網(wǎng)贊同其觀(guān)點(diǎn)和對其真實(shí)性負責;文章版權歸原作者及原出處所有,如涉及作品內容、版權和其它問(wèn)題,我們將根據著(zhù)作權人的要求,第一時(shí)間更正或刪除。
您需要登錄后才可以發(fā)表評論 登錄 | 立即注冊

相關(guān)視頻

關(guān)于我們  -  服務(wù)條款  -  使用指南  -  站點(diǎn)地圖  -  友情鏈接  -  聯(lián)系我們
電子工程網(wǎng) © 版權所有   京ICP備16069177號 | 京公網(wǎng)安備11010502021702
快速回復 返回頂部 返回列表
午夜高清国产拍精品福利|亚洲色精品88色婷婷七月丁香|91久久精品无码一区|99久久国语露脸精品|动漫卡通亚洲综合专区48页