Complete the code to set up the NavController in an Activity.
val navController = findNavController([1])The NavController is obtained by calling findNavController with the ID of the NavHostFragment, which is R.id.nav_host_fragment.
Complete the code to navigate to the destination fragment using NavController.
navController.[1](R.id.destinationFragment)popBackStack to go forward.To move to another fragment, use navigate with the destination ID.
Fix the error in the code to correctly set up the NavHostFragment in the Activity's layout.
<fragment
android:id="@+id/nav_host_fragment"
android:name="[1]"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:navGraph="@navigation/nav_graph"
app:defaultNavHost="true" />The android:name attribute must specify androidx.navigation.fragment.NavHostFragment to host the navigation graph.
Fill both blanks to create a NavOptions object that animates navigation transitions.
val options = NavOptions.Builder()
.setEnterAnim([1])
.setExitAnim([2])
.build()Use slide_in_right for entering and slide_out_left for exiting animations to create smooth transitions.
Fill all three blanks to create a safe args bundle and navigate with arguments.
val action = NavGraphDirections.actionToDetailFragment([1] = userId) navController.[2](action, [3])
bundleOf() instead of null when no options are needed.Pass the userId as argument, use navigate to move, and null for NavOptions if none are needed.