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

发布时间:2010-12-9 17:39    发布者:conniede
关键词: J2ME , 触摸屏 , 手机
在WTK目录下的WTK22wtklibdevicesDefaultColorPhoneDefaultColorPhone.properties的文件中有一行touch_screen=false,把它改成true。

MIDP2.0对于触摸屏方法有三个:

1.pointerDragged(int x, int 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 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;

}

}
本文地址:https://www.eechina.com/thread-45518-1-1.html     【打印本页】

本站部分文章为转载或网友发布,目的在于传递和分享信息,并不代表本网赞同其观点和对其真实性负责;文章版权归原作者及原出处所有,如涉及作品内容、版权和其它问题,我们将根据著作权人的要求,第一时间更正或删除。
您需要登录后才可以发表评论 登录 | 立即注册

厂商推荐

相关视频

关于我们  -  服务条款  -  使用指南  -  站点地图  -  友情链接  -  联系我们
电子工程网 © 版权所有   京ICP备16069177号 | 京公网安备11010502021702
快速回复 返回顶部 返回列表