Skip to content

Instantly share code, notes, and snippets.

@gsrathoreniks
Created October 28, 2020 10:29
Show Gist options
  • Save gsrathoreniks/72f7195275bc3f80e3b1207c17164e5f to your computer and use it in GitHub Desktop.
Save gsrathoreniks/72f7195275bc3f80e3b1207c17164e5f to your computer and use it in GitHub Desktop.
Sample code for VIEW BINDING in Fragments
private var _binding: FragmentProfileBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentProfileBinding.inflate(inflater, container, false)
val view = binding.root
return view
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment