使用J2ME技术实现手机触摸屏开发的方法
2010-07-16 13:43
639 查看
本文简单介绍了如何使用J2ME技术实现手机触摸屏开发的方法:
在WTK目录下的/WTK22/wtklib/devices/DefaultColorPhone/DefaultColorPhone.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 < menuWidth && y > (
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://www.guaiguaier.com 乖乖儿-育儿工具资源网
在WTK目录下的/WTK22/wtklib/devices/DefaultColorPhone/DefaultColorPhone.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 < menuWidth && y > (
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://www.guaiguaier.com 乖乖儿-育儿工具资源网
相关文章推荐
- 使用J2ME技术实现手机触摸屏开发的方法
- 使用J2ME技术实现简单的动画(附代码实现)
- 在J2ME手机程序开发中使用颜色
- 使用文本语音开发包实现语音朗读功能(VB方法)
- 使用J2ME技术开发RPG游戏(一)——程序框架
- Android应用开发中触摸屏手势识别的实现方法解析
- JAVA游戏编程之三----j2me 手机游戏入门开发--俄罗斯方块_5_使用LUA脚本写游戏
- 使用NetBeans进行J2ME开发(一):别让程序员的手机闲着
- JAVAWEB开发之Servlet3.0新特性的使用以及注解的详细使用和自定义注解的方法、动态代理的使用、利用动态代理实现细粒度的权限控制以及类加载和泛型反射
- 使用Java ME技术开发手机密码管理软件(已发《电脑编程技巧和维护》11月上)
- 使用ionic开发手机app中,设置tab中的icon为自定义图标的方法
- 使用J2ME技术开发RPG游戏(一)——程序框架
- 使用HTML5开发实现拍照上传应用的方法
- 使用J2ME技术开发RPG游戏(二)——按键处理机制
- [Unity3D]手机3D游戏开发:如何实现最高分的存储与显示(二)----使用GUI.Box显示文字
- 使用jquery.validate自定义方法实现"手机号码或者固话至少填写一个"的逻辑验证
- Android开发使用Handler的PostDelayed方法实现图片轮播功能
- 一个使用J2ME技术实现的计算器的代码
- 使用J2ME技术开发RPG游戏(一)——程序框架
- 使用WCF实现SOA面向服务编程——使用AJAX+WCF服务“.NET技术”页面开发