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);
}
}
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);
}
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言