Hi! View binding: If you have a custom view (class...
# android
l
Hi! View binding: If you have a custom view (class TodayBoxView: RelativeLayout) with inflated layout (R.layout.view_todaybox), where must to do ‘binding = ViewTodayboxBinding.bind(this)’ and where binding = null?
b
you can simply make
Copy code
private val binding = ViewTodayboxBinding.inflate(LayoutInflater.from(context), this, true)
👏 1
and you don't need to reset it to null
You need to do this only when lifecycle of binding's holder differs from view's lifecycle (for activity, fragment etc)
👍 1
l
Oh, great, thank you! I check it 🙂