I currently inflate most of my layouts using the DataBindingUtil.inflate(inflater, layoutId, parent, attachToParent)
method.
But I saw that their is an AsyncLayoutInflater
since Support Library revision 24
that allow the inflation to occur on a separate thread. I would like to use this mechanism in some part of my app but I don't want to drop the use of databinding
for that.
DataBindingUtil
doesn't contain any method like inflateAsync()
. But is it plan to add a support for that? Or is their a way to combine both the AsyncLayoutInflater
and the use of databinding
?
I tried to use the AsyncLayoutInflater
inside the inflate
method of DataBindingUtil
but actually AsyncLayoutInflater
is not a subclass of the original LayoutInflater
.
Thank's for reading!
You can just use DataBindingUtil.bind(view)
to bind to the root of the inflated layout.
new AsyncLayoutInflater(this).inflate(R.layout.my_layout, null, new AsyncLayoutInflater.OnInflateFinishedListener() {
@Override
public void onInflateFinished(@NonNull View view, int resid, @Nullable ViewGroup parent) {
MyLayoutBinding binding = DataBindingUtil.bind(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