Recall & Review
beginner
What is the Navigation Component in Android?
The Navigation Component is a part of Android Jetpack that helps you manage app navigation easily and consistently, handling fragment transactions and back stack automatically.
Click to reveal answer
beginner
Which XML file defines the navigation graph?
The navigation graph is defined in an XML file located in the res/navigation folder, usually named nav_graph.xml. It describes all destinations and actions.
Click to reveal answer
beginner
How do you add the Navigation Component dependencies in your Android project?
Add these dependencies in your app's build.gradle file:
implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
Click to reveal answer
beginner
What is the purpose of NavHostFragment?
NavHostFragment is a container that hosts navigation destinations (fragments). It swaps fragments as you navigate through the app.
Click to reveal answer
beginner
How do you trigger navigation to another fragment in Kotlin code?
Use the NavController to navigate, for example:
findNavController().navigate(R.id.destinationFragment)
This moves to the destination defined in the navigation graph.
Click to reveal answer
Where do you define the navigation graph XML file?
✗ Incorrect
The navigation graph XML file is placed inside the res/navigation folder.
Which class hosts the navigation destinations in your layout?
✗ Incorrect
NavHostFragment is the container that hosts navigation destinations (fragments).
How do you navigate to another fragment in Kotlin using Navigation Component?
✗ Incorrect
You use findNavController().navigate() with the destination ID to navigate between fragments.
Which dependencies are needed for Navigation Component in Kotlin?
✗ Incorrect
The Navigation Component requires navigation-fragment-ktx and navigation-ui-ktx dependencies.
What does the Navigation Component automatically handle for you?
✗ Incorrect
Navigation Component manages fragment transactions and back stack automatically.
Explain how to set up the Navigation Component in an Android Kotlin project from scratch.
Think about the files and code needed to make navigation work.
You got /4 concepts.
Describe the role of NavHostFragment and NavController in app navigation.
One is a container, the other is a controller.
You got /3 concepts.