Skip to content

Instantly share code, notes, and snippets.

@shanmugasanthosh7
Created May 26, 2018 14:42
Show Gist options
  • Save shanmugasanthosh7/7a0ae0092ab059d11b3cb23e1bf3c94b to your computer and use it in GitHub Desktop.
Save shanmugasanthosh7/7a0ae0092ab059d11b3cb23e1bf3c94b to your computer and use it in GitHub Desktop.
Create bundle argument
class BundleFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.fragment_bundle, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val bundle = Bundle()
bundle.putString("name", "Santhosh")
passBundle.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.action_bundleFragment_to_passBundleFragment, bundle))
//Or
// passBundle.setOnClickListener {
// val bundle = Bundle()
// bundle.putString("name","Santhosh")
// Navigation.findNavController(activity!!,R.id.my_nav_host_fragment).navigate(R.id.action_bundleFragment_to_passBundleFragment,bundle)
// }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment