Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Arguments on actions are only used for Safe Args currently so your example would work if you switch to using Safe Args and the Directions classes it generates:
actionOneBtn.setOnClickListener {
navController.navigate(ArgFragmentDirections.actionOne())
}
actionTwoBtn.setOnClickListener {
navController.navigate(ArgFragmentDirections.actionTwo(2))
}
actionThreeBtn.setOnClickListener {
navController.navigate(NavigationDirections.globalAction())
}
(I needed to make two changes to your XML to get it working: adding <argument android:name="type" app:type="integer"/> to action_two and changing the android:id for your root navigation element to "@+id/navigation")
We should fix NavOptions to parse arguments and pass them through, even if you're not using Safe Args.
actionOneBtn.setOnClickListener {
navController.navigate(ArgFragmentDirections.actionOne())
}
actionTwoBtn.setOnClickListener {
navController.navigate(ArgFragmentDirections.actionTwo(2))
}
actionThreeBtn.setOnClickListener {
navController.navigate(NavigationDirections.globalAction())
}
(I needed to make two changes to your XML to get it working: adding <argument android:name="type" app:type="integer"/> to action_two and changing the android:id for your root navigation element to "@+id/navigation")
We should fix NavOptions to parse arguments and pass them through, even if you're not using Safe Args.
il...@google.com <il...@google.com> #3
2m...@gmail.com <2m...@gmail.com> #4
Yes thank you, working as intended! Is it possible, to bind a UI (like nav bar,menu) to an action instead of a destination? That was my initial problem, although I wasn't sure if that is intended use at all. So tying a bottomNav bar to navigation actions, so that each action would have a default argument, that is passed to the same fragment, so the fragment would display different data each navigation. The fragment gets called, just the bundle is null.
It's in the bottomNavigation branch:https://github.com/2ma/NavigationActionBug/tree/bottomNavigation
It's in the bottomNavigation branch:
Description
Version used: 1.0.0-alpha03
Devices/Android versions reproduced on: Nexus 5 (6.0.1), Nexus 5x (8.1.0)
Expected behavior: When navigation action has an argument with default value, it should pass that to destination.
Actual behavior: Default value is is not used, passed bundle is empty.
Steps to reproduce:
I made this small app to demonstrate behavior: