所以下面我有一个GestureDetector,但整个过程在Eclipse中显示"Deprecated Constructor".
我正在使用它来检测flings,它工作得很好,但我找不到并行构造函数.整件事已被弃用.我要切换到什么?
无论如何,这是代码:
mGestureDetector = new GestureDetector( new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDown(MotionEvent e) { return true; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // Roll the ball in the direction of the fling Direction mCommandedRollDirection = Direction.NONE; if (Math.abs(velocityX) > Math.abs(velocityY)) { if (velocityX < 0) mCommandedRollDirection = Direction.LEFT; else mCommandedRollDirection = Direction.RIGHT; } else { if (velocityY < 0) mCommandedRollDirection = Direction.UP; else mCommandedRollDirection = Direction.DOWN; } if (mCommandedRollDirection != Direction.NONE) { mGameEngine.rollBall(mCommandedRollDirection); } return true; } }); mGestureDetector.setIsLongpressEnabled(false); }
显然,我想要相同的功能.那么我需要添加哪些新函数(如果有的话)以及我需要使用哪个构造函数?
(是的,我知道Android开发者文档,但就像我说我找不到更新版本的什么叫做GestureDetector)
谢谢!
交换这个:
GestureDetector gd = new GestureDetector(getActivity(), new OnGestureListener() { Methods for the listener }