2008年10月2日 星期四

A simple gesture detector for Android

Source code:
http://sites.google.com/site/urakagi/android-code-trunks

Usage:
New a ROGestureListener object, then setOnTouchListener() to it for all components in the activity.
Implements Callback methods, so the activity will catch gesture string when the gesture is done. (The gesture string is composed by U(p)/D(own)/L(eft)/R(ight))

Example:
public class Ex extends ListActivity implements ROGestureCallback {
private ROGestureListener mGestureListener = new ROGestureListener(this);

public void onCreate(Bundle savedInstanceState) {
...
mList.setOnTouchListener(mGestureListener);
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
return mGestureListener.onTouch(mList, ev);
}

public void onGestureDone(String gestureString) {
Log.v("Gesture=", gestureString);
}

}

沒有留言:

CODE { display: block; /* fixes a strange ie margin bug */ font-family: Courier New; font-size: 8pt; overflow:auto; background: #f0f0f0 url(http://klcintw.images.googlepages.com/Code_BG.gif) left top repeat-y; border: 1px solid #ccc; padding: 10px 10px 10px 21px; max-height:200px; height:200px; // for IE6 line-height: 1.2em; } #quote { display: block; /* fixes a strange ie margin bug */ font-family: Verdana; font-size: 10pt; overflow:auto; background: #f7f7f7 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKN19b4aT1DHj8GUNi63hQtkKMMZBz85Is4BxJdhPcfrcbaDczl_1lhtztSIirdEAoNLN5F-aDcr7pBSdyFbupvipv2q7vmWWhcqhgsf8nr_nH0jBKyn4YGlBfuiV-BOWA56z7mdE4XXo/s288/quote-l.gif) left top no-repeat; border: 4px dotted #ccc; padding: 15px 15px 15px 31px; /*up right bottom left*/ max-height:300px; line-height: 1.2em; }