手势识别
public class Gesture implements OnGestureListener { private GestureDetector gestureDetector; public void onTouchEvent(MotionEvent event) { gestureDetector.onTouchEvent(event); } public Gesture(Context context) { gestureDetector = new GestureDetector(context, this); } @Override public boolean onDown(MotionEvent e) { // TODO Auto-generated method stub return false; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // TODO Auto-generated method stub return false; } @Override public void onLongPress(MotionEvent e) { // TODO Auto-generated method stub } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // TODO Auto-generated method stub return false; } @Override public void onShowPress(MotionEvent e) { // TODO Auto-generated method stub } @Override public boolean onSingleTapUp(MotionEvent e) { // TODO Auto-generated method stub return false; } }
gesture = new Gesture(context);//在适当时刻初始化Gesture
gesture.onTouchEvent(event);//放在onTouchEvent中,即将event传递到gesture让其进行识别
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。