Created
October 28, 2020 10:29
-
-
Save gsrathoreniks/72f7195275bc3f80e3b1207c17164e5f to your computer and use it in GitHub Desktop.
Sample code for VIEW BINDING in Fragments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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