Java 不推荐使用手势检测器

Java 不推荐使用手势检测器,java,android-studio,Java,Android Studio,我使用的是android stoudio 2.3.3,copile-v7:26.0.0-alpha1,这个方法在这个版本中不起作用,但我尝试添加compile-v4:25.3.1是我的版本,也没什么 public CandidateView(Context context) { ... mGestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {

我使用的是android stoudio 2.3.3,copile-v7:26.0.0-alpha1,这个方法在这个版本中不起作用,但我尝试添加compile-v4:25.3.1是我的版本,也没什么

public CandidateView(Context context) {
       ...

        mGestureDetector =  new GestureDetector(new GestureDetector.SimpleOnGestureListener() { 

            @Override
            public boolean onScroll(MotionEvent e1,
                                    MotionEvent e2,
                                    float distanceX,
                                    float distanceY) {
                mScrolled = true;
                int sx = getScrollX();
                sx += distanceX;
                if (sx < 0) {
                    sx = 0;
                }
                if (sx + getWidth() > mTotalWidth) {
                    sx -= distanceX;
                }
                mTargetScrollX = sx;
                scrollTo(sx, getScrollY());
                invalidate();
                return true;
            }
        });

      ...
    }
公共候选视图(上下文){
...
mGestureDetector=new GestureDetector(new GestureDetector.SimpleOnGestureListener(){
@凌驾
公共布尔onScroll(运动事件e1,
运动事件e2,
浮动距离x,
浮动距离){
mScrolled=true;
int sx=getScrollX();
sx+=距离x;
if(sx<0){
sx=0;
}
如果(sx+getWidth()>mTotalWidth){
sx-=距离x;
}
mtargetx=sx;
scrollTo(sx,getScrollY());
使无效();
返回true;
}
});
...
}