Let's say we have the following code:
NavHost(
navController = navController,
startDestination = FRAGMENT_ONE
) {
composable(FRAGMENT_ONE) {
FragmentOneScreen()
}
composable(FRAGMENT_TWO) {
FragmentTwoScreen()
}
composable(FRAGMENT_THREE) {
FragmentThreeScreen()
}
}
FragmentOneScreen, FragmentTwoScreen, and FragmentThreeScreen are methods annotated with @composable, and NavHost code is placed in MainActivity's onCreate method.
My questions are:
I need some help with this because I am having a hard time grasping these questions.
They are composables.
NavHost(navController = navController, startDestination = SCREEN_ONE) {
composable(SCREEN_ONE) {
ScreenOne()
}
composable(SCREENT_TWO) {
ScreenTwo()
}
composable(SCREEN_THREE) {
ScreenThree()
}
}
Rename fragment
to screen or some other terms to avoid confusion.
Navigation can be done like this,
navController.navigate("friends")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.