Law Gimenez
06/11/2021, 9:05 AMprivate val binding get() = _binding!!
line. Thanks in advance for the help!wbertan
06/11/2021, 9:07 AMonCreateView
and after the onDestroyView
?
// This property is only valid between onCreateView and
// onDestroyView.
private val binding get() = _binding!!
wbertan
06/11/2021, 9:10 AMprivate var _binding: ResultProfileBinding? = null
// This property is only valid between onCreateView and
// onDestroyView.
private val binding: ResultProfileBinding get() {
println("test binding get")
return _binding!!
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
println("test onCreateView")
_binding = ResultProfileBinding.inflate(inflater, container, false)
val view = binding.root
return view
}
override fun onDestroyView() {
println("test onDestroyView")
super.onDestroyView()
_binding = null
}
Look in the Logcat to see if the test binding get
calls either before the test onCreateView
or after the test onDestroyView
.Law Gimenez
06/11/2021, 9:18 AMonCreateView
and after onDestroyView
. I did follow everything on the Android documentation link. I will try your implementation.wbertan
06/11/2021, 9:21 AMonDestroyView
in some cases only due to the leak 😞Law Gimenez
06/11/2021, 9:22 AMBottomNavigationView
. It seems ViewBinding can’t catch up on the rendering.Law Gimenez
06/11/2021, 9:23 AMwbertan
06/11/2021, 9:27 AMonDestroyView
.
In some places after migrating to View Binding we also had to explicitly remove listeners on the onDestroyView
.Joost Klitsie
06/11/2021, 2:49 PMJoost Klitsie
06/11/2021, 2:50 PMLaw Gimenez
06/11/2021, 3:27 PM