Skip to content

Instantly share code, notes, and snippets.

@danielwilson1702
Last active September 5, 2015 11:39
Show Gist options
  • Save danielwilson1702/ea0fb5213e75e65653d3 to your computer and use it in GitHub Desktop.
Save danielwilson1702/ea0fb5213e75e65653d3 to your computer and use it in GitHub Desktop.
Swapping a fragment - standard
Bundle args = launchingFragment.getArguments();
if (args == null) {
args = new Bundle();
}
if (mMyObject != null) {
args.putSerializable(Constants.Args.MY_OBJECT, mMyObject);
}
Fragment myNiceFragment = MyNiceFragment.instantiate(mContext, MyNiceFragment.class.getName(), args);
getSupportFragmentManager().beginTransaction()
.replace(R.id.content_container, myNiceFragment, myNiceFragment.getClass().getSimpleName())
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.addToBackStack(null)
.commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment