val button = view.findViewById<Button>(R.id.navigate_destination_button) button?.setOnClickListener( Navigation.createNavigateOnClickListener(R.id.flow_step_one_dest, null) )
1 2 3 4 5 6
// Note the usage of curly braces since we are defining the click listener lambda view.findViewById<Button>(R.id.navigate_action_button)?.setOnClickListener { val flowStepNumberArg = 1 val action = HomeFragmentDirections.nextAction(flowStepNumberArg) findNavController().navigate(action) }
更多 Navigation
menu
drawer
bottom
DeepLink
1 2 3 4 5 6 7 8 9
val args = Bundle() args.putString("myarg", "From Widget"); val pendingIntent = NavDeepLinkBuilder(context) .setGraph(R.navigation.mobile_navigation) .setDestination(R.id.deeplink_dest) .setArguments(args) .createPendingIntent()