Code example for ViewFlipper

Methods: getChildCount, getDisplayedChild

2
            this.indicator = indicator;
        } 
 
        @Override 
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            int displayedChild = viewFlipper.getDisplayedChild();
            int childCount = viewFlipper.getChildCount();
            float sensitvity = 50;
            if ((e1.getX() - e2.getX()) > sensitvity) {
                if (displayedChild == childCount - 1) {
                    return false; 
                } else { 
                    swipeLeft(viewFlipper);
                    indicator.setCurrentDisplayedChild(displayedChild);
                } 
            } else if ((e2.getX() - e1.getX()) > sensitvity) {
                if (displayedChild <= 0) {
                    return false; 
                } else { 
                    swipeRight(viewFlipper);
                    indicator.setCurrentDisplayedChild(displayedChild);