I saw some examples where binding were defined and used in onCreateView() using inflate() and in onViewCreated() using bind().
What's the difference? And where is it better to operate with our views(RecyclerView, TextView and so on)?
Google documentation shows example like this:
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = ResultProfileBinding.inflate(inflater, container, false)
val view = binding.root
return view
}
But also in some articles we can see something like this:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
_binding = ResultProfileBinding.bind(view)
}