Closed DJDrama closed 3 months ago
private var _binding: ResultProfileBinding? = 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 = ResultProfileBinding.inflate(inflater, container, false)
val view = binding.root
return view
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
Just use like above (Sample in official docs) closing this issue
Question
In Android Developers guide (https://developer.android.com/topic/libraries/view-binding) we nullify binding vairable after super.onDestroyView()
But when we look at the viewbinding sample, the binding variable is nullified before super.onDestroyView()
What is the correct way? Official developers site's guide or sample?