Last active
February 24, 2016 15:53
-
-
Save trinnguyen/db15e7d6b15155a5d819 to your computer and use it in GitHub Desktop.
Android Fragment for SetRootViewModel and PushViewModel like iOS UINavigationController
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
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