jetpack navigation 向startDestination传送数据

XML 代码中不设置grap


	
	   

navigation grap 布局 nav_activity_main.xml




    
        
    

MainActivity中

var name = "harveyhaha"
val args = NewsFragmentArgs(name)
Navigation.findNavController(this, R.id.main_nav_fragment)
	.setGraph(R.navigation.nav_activity_main, args.toBundle())

NewsFragment接收

class NewsFragment : Fragment(){
	val args: NewsFragmentArgs by navArgs()
}

你可能感兴趣的:(Android)