I am working o na Android app. This app has tutorial screens. In this tutorial user has to slide right and left to complete the tutorial. When it launches the app it shows first fragment called SwipeLeftFragment. When user swipes left it shows second fragment called SwipeRightFragment. When user swipes right it shows third fragment called CompletedTutorialFragment. Currently It works fine but animation doesn't work. Following is my code:
public class TutorialActivity extends FragmentActivity {
@Override
protected void onStart() {
super.onStart();
final swipeLeftFragment swipeLeftFragment = new SwipeLeftFragment();
addFragmentToBottom(swipeLeftFragment);
swipeLeftFragment.getView().setOnTouchListener(new OnSwipeListener(TutorialActivity.this) {
@Override
public void onSwipeRight() {
}
@Override
public void onSwipeLeft() {
TranslateAnimation animation = new TranslateAnimation(0, -swipeLeftFragment.getView().getWidth(), 0, 0);
animation.setDuration(5000);
swipeLeftFragment.getView().startAnimation(animation);
swipeLeftFragment.getView().setVisibility(View.GONE);
final SwipeRightFragment swipeRightFragment = new SwipeRightFragment();
addFragmentToBottom(swipeRightFragment);
swipeRightFragment.getView().setOnTouchListener(new OnSwipeListener(TutorialActivity.this) {
@Override
public void onSwipeRight() {
TranslateAnimation animation = new TranslateAnimation(0, +swipeRightFragment.getView().getWidth(), 0, 0);
animation.setDuration(5000);
swipeRightFragment.getView().startAnimation(animation);
swipeRightFragment.getView().setVisibility(View.GONE);
final CompletedTutorialFragment completedTutorialFragment = new CompletedTutorialFragment();
addFragmentToBottom(completedTutorialFragment);
startSignupActivity();
}
@Override
public void onSwipeLeft() {
}
});
}
});
}
private void startSignupActivity() {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(TutorialActivity.this, SignUpActivity.class));
}
}, 2000L);
}
}
Can someone tell me whats wrong with my code?
this is the OnTouchListener I am using