I am trying to move one of my project onto viewbinding. at one of the places i use an android layout resource i.e
android.R.layout.simple_list_item_1 from what i know, if i have a layout
R.layout.layout_x, i get a generated binding class as
LayoutXBinding.class whose instance i can generate via .bind() or .inflate(…). But how to get binding for system layouts?
On a similar note, I am currently working on a project that uses a kind of generic adapter for dealing with various layouts. its not exactly generic, but a adapter creating views of multiple types and a view holder receiving and working on such views accordingly.
The synthetic binding is great in this area, helping me reduce the boilerplate by a lot. sealed classes also helps as i get all the different data modal types at one place.
to add any new item type , i just need to create its modal, add an associated entry
getAllSubclassDetailsMap and add the attachment logic in viewholder. the adapter automatically extracts the layout , inflates view and returns it to holder.
So i wish to use viewbinding in this. is there some static function say
ViewBindingMaster.getBinding(layoutRes:Int):T such that if i pass it
ViewBindingMaster.getBinding(R.layout.activity_main) , I get an instance of
ActivityMainBinidng with which i could easily use in viewholder?