成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

S40 Touch API - Gesture API

移動(dòng)開發(fā)
利用觸摸屏的手勢(shì)操會(huì)使得應(yīng)用程序的用戶體驗(yàn)大大提升,比如用Drag進(jìn)行屏,用Flick進(jìn)行滾動(dòng)等。

利用觸摸屏的手勢(shì)操會(huì)使得應(yīng)用程序的用戶體驗(yàn)大大提升,比如用Drag進(jìn)行屏,用Flick進(jìn)行滾動(dòng)等。

從S40_6th_Edition_FP1開始,諾基亞S40 SDK中加入了com.nokia.mid.ui.gestures 包,對(duì)觸摸屏手勢(shì)進(jìn)行支持。開發(fā)者無需再自己實(shí)現(xiàn)手勢(shì)識(shí)別引擎。Nokia Gesture API包由兩個(gè)接口和兩個(gè)類組成。

接口

GestureEvent

The GestureEvent interface class is used by an application to receive gesture recognition events from the platform.

GestureListener

This interface is used by applications which need to receive gesture events from the implementation.

GestureInteractiveZone

The GestureInteractiveZone class is used by an application to define an area of the screen that reacts to a set of specified gestures.

GestureRegistrationManager

The GestureRegistrationManager class provides the ability to register a GestureListener to be notified when a gesture event occurs within a container.

Gesture API采用了觀察者設(shè)計(jì)模式。

第一步:創(chuàng)建GestureInteractiveZone實(shí)例

GestureInteractiveZone定義了一個(gè)可以接收手勢(shì)事件的區(qū)域。缺省的GestureInteractiveZone包括整個(gè)屏幕。GestureInteractiveZone同時(shí)注冊(cè)了MIDlet響應(yīng)哪些手勢(shì)事件。

// 創(chuàng)建一個(gè)相應(yīng)所有手勢(shì)事件的GestureInteractiveZone 對(duì)象 GestureInteractiveZone giz = new GestureInteractiveZone( GestureInteractiveZone.GESTURE_ALL ); // 設(shè)置相應(yīng)區(qū)域 giz.setRectangle( x, y, width, height);

在GestureInteractiveZone中定義了可被識(shí)別的手勢(shì):

static int GESTURE_ALL Constant for All Gesture Events.

static int GESTURE_DRAG Constant for the Drag Gesture.

static int GESTURE_DROP Constant for the Drop Gesture.

static int GESTURE_FLICK Constant for the Flick Gesture.

static int GESTURE_LONG_PRESS Constant for the Long Press Gesture.

static int GESTURE_LONG_PRESS_REPEATED Constant for the Long Press Repeated Gesture.

static int GESTURE_TAP Constant for the Tap Gesture.

第二步,實(shí)現(xiàn)GestureListener接口

GestureListener接口只定義了一個(gè)方法:gestureAction(), 當(dāng)系統(tǒng)的手勢(shì)識(shí)別引擎探測(cè)到在第一步中注冊(cè)了的手勢(shì)后,這個(gè)方法會(huì)被調(diào)用。該方法每次被調(diào)用時(shí)會(huì)接收到一個(gè)GestureEvent實(shí)例。GestureEvent中保存有最后接收到的手勢(shì)事件的參數(shù)。

public void gestureAction(Object container, GestureInteractiveZone gestureZone, GestureEvent gestureEvent)
{
switch( event.getType() ) {
case GestureInteractiveZone.GESTURE_TAP:
...;
break;
case GestureInteractiveZone.GESTURE_LONG_PRESS:
case GestureInteractiveZone.GESTURE_LONG_PRESS_REPEATED:
case GestureInteractiveZone.GESTURE_DRAG:
case GestureInteractiveZone.GESTURE_DROP:
case GestureInteractiveZone.GESTURE_FLICK:
}
}

GestureEvent接口中定義了大量的get方法。 對(duì)于所有的手勢(shì)事件都可以得到x,y坐標(biāo);

int getFlickSpeedX() Query for the Flick gesture events speed in horizontal direction.

int getFlickSpeedY() Query for the Flick gesture events speed in vertical direction.

對(duì)于DRAG 和 DROP事件還可以分別得到x和y方向上變化的距離;

int getDragDistanceX()
Query for the Drag & Drop gesture events movement in horizontal direction since last drag gesture.
int getDragDistanceY()
Query for the Drag & Drop gesture events movement in vertical direction since last drag gesture.

對(duì)于FLICK事件,可以得到移動(dòng)的速度和方向;

float getFlickDirection() Query for the Flick gesture events direction.

int getFlickSpeed() Query for the Flick gesture events speed in actual flick direction.

int getFlickSpeedX() Query for the Flick gesture events speed in horizontal direction.

int getFlickSpeedY() Query for the Flick gesture events speed in vertical direction.

第三步,注冊(cè)GestureInteractiveZone和Listener

GestureRegistrationManager類

static boolean register(java.lang.Object container, GestureInteractiveZone gestureInteractiveZone)
Register a gesture interactive zone to a container.
static void setListener(java.lang.Object container, GestureListener listener)
Add a listener to the a container.

這兩個(gè)方法的參數(shù)中都包括了一個(gè)容器類( Canvas 或者 CustomItem)。下面的代碼演示了如何注冊(cè)GestureInteractiveZone和Listener:

// 注冊(cè)GestureInteractiveZone
Canvas canvas = new GestureCanvas();
GestureRegistrationManager.register( canvas, giz );

//注冊(cè) Listener
GestureRegistrationManager.setListener(canvas, this);

使用Gesture API時(shí)應(yīng)注意:

1. 不要在gestureAction(…)方法中阻塞UI線程。

2. 不要將gestureAction(…)以外的變量指向GestureEvent實(shí)例。

代碼示例 Media:TouchSample.zip

 

責(zé)任編輯:Yeva 來源: NOKIA Developer
相關(guān)推薦

2013-01-25 14:44:47

S40Series 40

2013-01-25 14:56:23

S40Series 40

2013-01-25 15:04:30

S40Series 40

2011-04-25 17:17:55

Gesture APIWindows Mob

2013-01-25 13:49:26

S40Series 40

2013-01-25 14:08:32

S40Series 40

2013-01-25 15:29:14

s40Series 40

2013-01-25 14:06:17

S40Series 40

2012-03-26 21:45:13

S40

2013-10-31 14:30:44

CloudaAPI

2011-09-02 16:08:09

Sencha ToucAPI文檔

2012-02-02 09:06:44

SymbianS40諾基亞

2012-12-14 14:48:01

諾基亞Series 40S40

2024-06-26 00:22:35

2021-08-09 08:20:59

API安全測(cè)試漏洞

2014-12-22 10:28:47

2023-06-26 18:13:56

開源API

2012-04-13 09:17:19

微軟API必應(yīng)搜索

2022-11-24 13:17:43

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 欧美视频区 | 亚洲精品久久区二区三区蜜桃臀 | 国产99久久 | 欧美一级片在线观看 | 精品国产乱码一区二区三区 | 久久草视频| 精品久久久久国产免费第一页 | av色在线 | 97超碰人人 | 久久成人18免费网站 | 91亚洲国产 | 国产区在线观看 | 伊人久久成人 | 欧美xxxx色视频在线观看免费 | 亚洲国产精品视频一区 | 亚洲成人精品在线 | 欧美日韩国产一区二区 | 黄色大片在线播放 | 久久精品国产v日韩v亚洲 | 欧美日韩一区二区三区视频 | 久久最新精品 | 日本激情视频在线播放 | 国产精品69av | 天天想天天干 | 一区二区av在线 | 欧美一区二区三区在线播放 | 欧美精品在线看 | 一级毛片在线播放 | 国产精品久久久99 | 欧美久久久久久 | 日韩国产在线观看 | 欧美不卡视频一区发布 | 欧美日韩在线观看视频 | 黄色免费观看 | 国产日韩欧美 | 国产超碰人人爽人人做人人爱 | 亚洲精品中文字幕在线观看 | 嫩草国产 | 国产精品久久久久久久久久 | 97伦理电影 | 日韩一区欧美一区 |