Ali*_*ine 5 android android-jetpack-compose
错误:
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/book_screen } cannot be found
Run Code Online (Sandbox Code Playgroud)
导航根主机:
animatedCompose("${Graph.BOOK}/{id}",
arguments = listOf(
navArgument("id"){
type = NavType.LongType
defaultValue = -1
}
)
){
val id = it.arguments?.getInt("id") ?: -1
val actionText = if(id != -1) "Save" else "Add"
val title = if(id != -1) "Edit Book" else "Add New Book"
BookScreen(navHostController, title=title, actionText=actionText)
}
Run Code Online (Sandbox Code Playgroud)
从另一个屏幕内:
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick = {
rootNavHostController.navigate(Graph.BOOK)
}) {
Icon(Icons.Filled.Add,null)
}
}
Run Code Online (Sandbox Code Playgroud)
我认为,您可以将{id}可选参数作为参数。但是,不确定为什么现在不起作用。
通过这样做解决了它:
animatedCompose("${Graph.BOOK}/?id={id}",
arguments = listOf(
navArgument("id"){
type = NavType.IntType
defaultValue = -1
}
){}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3633 次 |
| 最近记录: |