Android 安卓碎片/手势检测,上下

Android 安卓碎片/手势检测,上下,android,android-fragments,gesture,Android,Android Fragments,Gesture,我有一个可用的fragment类,其中在抛出时需要调用fragment x,在抛出时需要调用fragment y,检查多个解决方案力工作请提供代码 public class Image_1 extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle args) { final View view = inflater.inflate(R

我有一个可用的fragment类,其中在抛出时需要调用fragment x,在抛出时需要调用fragment y,检查多个解决方案力工作请提供代码

public class Image_1 extends Fragment   {
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle args) {
        final View view = inflater.inflate(R.layout.image1_activity, container, false);
/////fling up 
///--->fragment x 
/////fling down
///--->fragment y 
        return view;
    }
}

你应该可以用GestureDetector来做,你试过了吗?应该可以,你只需要知道fling是向上还是向下,你在onFling中试过什么?公共布尔onDown(MotionEvent e){//TODO自动生成的方法存根Toast.makeText(getActivity(),“down”,Toast.LENGTH_LONG).show();返回true;}@Override public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){//TODO自动生成的方法存根Log.i(“Test”,“On Fling”);Toast.makeText(getActivity(),“Fling”,Toast.LENGTH_LONG).show();return true;}为了检查我给出的祝酒词,力来了你在调用gesturedetector.onTouchEvent()传递运动事件吗?尝试onInterceptTouchEvent(motionevent){gesturedetector.onTouchEvent(motionevent);}