Step #7: Wiring in the Navigation
We need to switch MainActivity
to use this re-created activity_main
layout resource. So, change the onCreate()
function in MainActivity
to be:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
If you now run the app, it should give you the same result as before we added the fragment:
When we add new screens in upcoming tutorials, we will:
- Create fragments for those screens
- Add those as destinations in our navigation graph, connecting them with previous screens to indicate how we move from one to the next
- Add some Kotlin code to say “let’s navigate from where we are to this destination”
And the rest will be taken care of by the Navigation component.
Prev Table of Contents Next
This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.