Skip to content

Instantly share code, notes, and snippets.

@abhishekBansal
Created February 1, 2021 18:39
Show Gist options
  • Select an option

  • Save abhishekBansal/d5e2a2e1d1b6b9f1af155816b27a6991 to your computer and use it in GitHub Desktop.

Select an option

Save abhishekBansal/d5e2a2e1d1b6b9f1af155816b27a6991 to your computer and use it in GitHub Desktop.
class DemoFragment : Fragment() {
// declare binding
private var binding: FragmentDemoBinding? = null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// inflate and return view
binding = FragmentDemoBinding.inflate(inflater, container, false)
return binding?.root
}
override fun onDestroyView() {
super.onDestroyView()
// make it null to handle different view lifecycle in fragments
binding = null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment