setContent {
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = "first"
){
composable("first"){
FirstScreen()
}
composable("second"){
SecondScreen()
}
composable("third"){
}
}
}
@Composable
fun FirstScreen() {
}
@Composable
fun SecondScreen() {
}
@Composable
fun ThirdScreen() {
}
이동
navController.navigate("second")
뒤로가기
navController.naviagteUp() or navController.popBackStack()
third가 실행될때 값을 넘기기
아래와 같이 넘기면되는데,
navController.navigate("third/$value")
composable선언시. 이렇게 받아올 수 있다.
composable("third/{value}") { backStackEntry->
ThirdScreen(
navController = navController,
value = backStackEntry.arguments?.getString("value")?:"",
)
}
728x90
'Software Development > Application Develop' 카테고리의 다른 글
Compose ViewModel (0) | 2024.07.28 |
---|---|
Android Zetpack Compose 기초 (0) | 2024.07.27 |
Kotlin-Coroutines (0) | 2024.07.21 |
Android Sensor (0) | 2022.10.28 |
How to create walking step counter App using Accelerometer sensor and Shared Preference in Android? (0) | 2022.10.28 |