Implementing Swipe action on ViewFlipper with multiple GridViews

前端 未结 3 520
Happy的楠姐
Happy的楠姐 2021-02-06 19:49

I have the following code to listen to Swipe action to navigate between GridViews in my ViewFlipper. However, it detects the Swipe inconsistently. I added the Gesture Listener t

3条回答
  •  广开言路
    2021-02-06 20:02

    1) have u added all the gridviews in viewflipper.

    viewFlipper = (ViewFlipper)findViewById(R.id.flipper);
                slideLeftIn = AnimationUtils.loadAnimation(this, R.anim.slide_left_in);
                slideLeftOut = AnimationUtils.loadAnimation(this, R.anim.slide_left_out);
                slideRightIn = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
                slideRightOut = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);
    
                gestureDetector = new GestureDetector(new MyGestureDetector());
                gestureListener = new View.OnTouchListener() 
                    {
                        public boolean onTouch(View v, MotionEvent event) 
                        {
                            if (gestureDetector.onTouchEvent(event)) 
                            {
                                    return true;
                            }
                            else{
                                    return false;}
                            }
                    };
    

    I have added these in my code it is working fine.just check this let me know

提交回复
热议问题