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:

ToDo App, After Switching to Fragment and Navigation
ToDo App, After Switching to Fragment and Navigation

When we add new screens in upcoming tutorials, we will:

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.