Last active
June 20, 2019 19:16
-
-
Save ceruleanotter/c41c61142c281c08dcf1bf4391e9abeb to your computer and use it in GitHub Desktop.
ViewModel Integrations: NavGraph with a ViewModel Example 4
This file contains hidden or 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 onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Other fragment setup code | |
NavController navController = NavHostFragment.findNavController(this); | |
ViewModelProvider viewModelProvider = new ViewModelProvider(this, | |
navController.getViewModelStore(R.id.checkout_graph)); | |
CheckoutViewModel viewModel = viewModelProvider.get(CheckoutViewModel.class); | |
// Use Checkout ViewModel | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment