0

i am using viewflipper and gesturedetector in my application for swiping the pages.i am able to swap a page. now i want to go on the next activity in my application on swapleft method. in the swapleft i added one method page.showNext().now i want to switch to next activity.

here it is my activity.class

public class eDetailing extends Activity 
{    


    ViewFlipper page;

Animation animFlipInForeward;
Animation animFlipOutForeward;
Animation animFlipInBackward;
Animation animFlipOutBackward;




@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    page = (ViewFlipper)findViewById(R.id.main_flipper_view);

    animFlipInForeward = AnimationUtils.loadAnimation(this, R.anim.flipin);
    animFlipOutForeward = AnimationUtils.loadAnimation(this, R.anim.flipout);
    animFlipInBackward = AnimationUtils.loadAnimation(this, R.anim.flipin_reverse);
    animFlipOutBackward = AnimationUtils.loadAnimation(this, R.anim.flipout_reverse);


    //findViewById(R.id.main_linear).setOnClickListener(this);


}

private void SwipeRight(){
    page.setInAnimation(animFlipInBackward);
    page.setOutAnimation(animFlipOutBackward);
    page.showPrevious();
}


private void SwipeLeft(){
    page.setInAnimation(animFlipInForeward);
    page.setOutAnimation(animFlipOutForeward);
    page.showNext();

}

@Override
public boolean onTouchEvent(MotionEvent event) {


    return gestureDetector.onTouchEvent(event);
}

SimpleOnGestureListener simpleOnGestureListener 
= new SimpleOnGestureListener(){

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {

        float sensitvity = 50;
        if((e1.getX() - e2.getX()) > sensitvity){
            SwipeLeft();
        }else if((e2.getX() - e1.getX()) > sensitvity){
            SwipeRight();
        }

        return true;
    }

};

GestureDetector gestureDetector
= new GestureDetector(simpleOnGestureListener);

}

here it is my xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="horizontal">

 <ViewFlipper 
      android:id="@+id/main_flipper_view"
    android:layout_height="540dip" android:layout_width="1020dip">
       <LinearLayout
       android:layout_height="fill_parent"
       android:layout_width="fill_parent"
       android:orientation="horizontal">
        <ImageView android:id="@+id/main_imageview" android:background="@drawable/img_main" android:layout_height="fill_parent" android:layout_width="fill_parent"></ImageView>
       </LinearLayout>
 </ViewFlipper>

and i am using flipin,flipout,flipinreverse,flipoutreverse xml files in anim. could anyone have an idea?

Also i want to add menu on the activity and menu will operate different pages. is this possible with page swiping effect using viewflipper and gesturedetector?

thanks in advance.

naleshmadur
  • 95
  • 1
  • 10

2 Answers2

0

Call startActivity

PravinCG
  • 7,688
  • 3
  • 30
  • 55
0

U Can do like this

     private void SwipeLeft(){
page.setInAnimation(animFlipInForeward);
page.setOutAnimation(animFlipOutForeward);
page.showNext();
Intent activityintent=new Intent();
activityintent.setClass(getApplicationContext(), targetactivity.class);
 startActivity(activityintent);

}

user1213202
  • 1,305
  • 11
  • 23