make animation like page changing when swiped

android

Solution

use : push_left_in.xml

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">    
 <translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="300"/>  
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" />  

and push_left_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">

<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="300"/>
    <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="300" />
</set>

all xml are located in res/anim and are called like this

    Intent i = new Intent(this,MainActivity.class);         
    startActivityForResult(i,ACTIVITY_EDIT);
    overridePendingTransition(R.anim.push_left_in,R.anim.push_left_out);    

Problem

i have an application for which i use SimpleGestureFilter.java and what it does is calling the right function on swipe (left right double tap...etc) here is part of the code ``` @Override public boolean dispatchTouchEvent(MotionEvent me){ // Call onTouchEvent of SimpleGestureFilter class this.detector.onTouchEvent(me); return super.dispatchTouchEvent(me); } public void onSwipe(int direction) { String str = ""; switch (direction) { case SimpleGestureFilter.SWIPE_RIGHT : minusOne(); str = "Swipe Right"; break; case SimpleGestureFilter.SWIPE_LEFT : plusOne(); str = "Swipe Left"; break; } } ``` So what i want to do it when plusOne() is caled or some of the other functions it does something and it submits intent on the same MainActivity.java class , I am trying to achive when that event happens to look like a book page slide , to have somesort of transitions between screens altought it is only one MainActivity screen ``` Intent i = new Intent(this,MainActivity.class); i.putExtra(DBAdapter.KEY_pk_ymd, Integer.parseInt(dt)); startActivityForResult(i,ACTIVITY_EDIT); ```

Original source