Last active
April 13, 2017 23:55
-
-
Save MohammedRashad/c99daf8c53c5dd5e6a4893baa7c06a0e to your computer and use it in GitHub Desktop.
Helper Class to move between fragments in android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dummy.app; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentTransaction; | |
public class FragmentChange { | |
FragmentTransaction fragmentTransaction; | |
public void setCurrentFragment(Fragment newFragment, Context mContext) { | |
fragmentTransaction = mContext.getSupportFragmentManager().beginTransaction(); | |
fragmentTransaction.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left); | |
fragmentTransaction.replace(R.id.mainFrame, newFragment); | |
fragmentTransaction.addToBackStack(null); | |
fragmentTransaction.commit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. I had to tweak it, but it gave me that right idea. Cheers!