Skip to content

Instantly share code, notes, and snippets.

@trinnguyen
Last active February 24, 2016 15:53
Show Gist options
  • Save trinnguyen/db15e7d6b15155a5d819 to your computer and use it in GitHub Desktop.
Save trinnguyen/db15e7d6b15155a5d819 to your computer and use it in GitHub Desktop.
Android Fragment for SetRootViewModel and PushViewModel like iOS UINavigationController
public void SetRootFragment(BaseFragment fragment)
{
//clear all
SupportFragmentManager.PopBackStackImmediate(null, Android.Support.V4.App.FragmentManager.PopBackStackInclusive);
//replace
SupportFragmentManager.BeginTransaction()
.Replace(Resource.Id.content_frame, fragment)
.CommitAllowingStateLoss();
}
public void PushFragment(BaseFragment fragment)
{
SupportFragmentManager.BeginTransaction()
.Replace(Resource.Id.content_frame, fragment)
.AddToBackStack(null)
.CommitAllowingStateLoss();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment