Let's assume I have my layout file myview.xml which created with databinding in mind. Then android will generate MyViewBinding class for me. And in some examples I saw code like this:
MyViewBinding mbinding = DataBindingUtils.inflate(inflatter, R.layout.myview, parent, false)
/// using mbinding somehow.
However if I don't want to use DataBindingUtils and wan't to use MyViewBinding directly I'm facing with the problem. MyViewBinding.inflate have different signature than DataBindingUtils.inflate and don't accept layout id (in this example it's R.layout.myview) as parameter.
So my question is - if I'm using generated binding class like MyViewBinding how could I say it which layout file it should use?
The binding class name is generated from the layout file. There is a 1-1 mapping between the layout file and the binding class so when you use MyViewBinding.inflate, it will use R.layout.my_view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With