in your app:menu of the one in the navigation graph. class MainActivity : AppCompatActivity() { … private fun setupBottomNavigationView() { val navController = findNavController(R.id.my_nav_host_fragment) bottomNavigationView?.setupWithNavController(navController) } }
[Destination Fragment Name]Args. With actions The other one class named [Current fragment name]Directions. override fun onViewCreated(view: View, savedInstanceState: Bundle?) { arguments?.let { val passedArguments = Action1Args.fromBundle(it) actionTextView.text = passedArguments.ARG_ACTION1 } } v.findViewById<Button>(R.id.button)?.setOnClickListener { val navController = v.findNavController() val action = HomeDirections.action_home_to_action1() action.setARG_ACTION1("GDG is COOL") navController.navigate(action) }
Nav Graph A Nav Graph B Link activities by adding an activity destination in the graph. To navigate to another activity use ActivityNavigator ActivityNavigator(Context context).navigate(ActivityNavigator.Destination destination, Bundle args, NavOptions navOptions)