Created
May 17, 2016 11:57
-
-
Save atultiwari/d591d9826d0efc8e1b680605dadaf617 to your computer and use it in GitHub Desktop.
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
private void LoadFragment(String fragmentName, boolean addToBackStack) { | |
Bundle args = new Bundle(); | |
Fragment fragment = null; | |
if(fragmentName == "HomeFragment") { | |
fragment = new HomeFragment(); | |
args.putBoolean("hasValues", false); | |
} else if(fragmentName == "SettingsFragment") { | |
fragment = new SettingsFragment(); | |
args.putBoolean("hasValues", false); | |
} else if(fragmentName == "HelpFragment") { | |
fragment = new HelpFragment(); | |
args.putBoolean("hasValues", false); | |
} | |
if (fragment != null) { | |
FragmentManager fragmentManager = getSupportFragmentManager(); | |
fragment.setArguments(args); | |
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); | |
//fragmentTransaction.setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit); | |
fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right); | |
//fragmentTransaction.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right); | |
fragmentTransaction.replace(R.id.container_body, fragment); | |
if(addToBackStack){ | |
fragmentTransaction.addToBackStack(null); | |
} | |
fragmentTransaction.commit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment