How to switch from one to two or more views in order like one by one view by swiping without using View flipper?

StackOverflow https://stackoverflow.com/questions/14495991

문제

 class MyGestureDetector extends SimpleOnGestureListener {

    @Override
    public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) 
    {
         dX =event2.getX()-event1.getX();
         dY =event1.getY()-event2.getY();
        if (Math.abs(dY)<SWIPE_MAX_OFF_PATH &&Math.abs(velocityX)>=SWIPE_THRESHOLD_VELOCITY &&Math.abs(dX)>=SWIPE_MIN_DISTANCE ) 
        {
            swipe=new ViewFlipper(MainActivity.this);
            if (dX>0) 
            {
                result=false;
                Toast.makeText(MainActivity.this,"Right swipe",Toast.LENGTH_LONG).show();
            } 
            else 
            {

                result=true;
                Toast.makeText(MainActivity.this,"Left swipe",Toast.LENGTH_LONG).show();
            }
         } 
         else 
            {
        result=false;   
            }
        return result;
         }
    }

It works fine for me. But when I swipe left to right, it goes from first view to sixth view (1st page to 6th page). How can I do this?

How to reduce the speed? Why does it goes from first view to sixth view? Totally I have 10 views in my app. I am working on Android 2.2 version.

도움이 되었습니까?

해결책

You can use JakeWharton's Sherlock view pager indicator. Refer this.

https://github.com/JakeWharton/Android-ViewPagerIndicator that will support in all

version. Hope it might help you.

다른 팁

You can use use ViewPager with ActionBarSherlock and Android Support Library for earlier versions .. Good luck

What is the equivalent of ActionBar in earlier sdk versions?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top