将AsyncLayout Inflater用于数据绑定

原学程将引见将AsyncLayout Inflater用于数据绑定的处置办法,这篇学程是从其余处所瞅到的,而后减了1些海外法式员的疑问与解问,愿望能对于您有所赞助,佳了,上面开端进修吧。

将AsyncLayout Inflater用于数据绑定 教程 第1张

成绩描写

我今朝应用DataBindingUtil.inflate(inflater, layoutId, parent, attachToParent)办法收缩我的年夜部门结构。

但是我瞅到它们是1个AsyncLayoutInflater,由于Support Library revision 二四许可在零丁的线程上产生收缩。我愿望在我的运用法式的某些部门应用此体制,但是我没有想为此废弃应用databinding

DataBindingUtil没有包括所有相似inflateAsync()的办法。但是它能否筹划增长对于这1面的支撑?或许它们是同时应用AsyncLayoutInflater以及databinding的1种方法吗?

我测验考试在DataBindingUtilinflate办法中应用AsyncLayoutInflater,但是现实上AsyncLayoutInflater没有是原初LayoutInflater的子类。

感激您的浏览!

推举谜底

您不妨只应用DataBindingUtil.bind(view)绑定到缩小结构的根。

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);
 }
});

佳了闭于将AsyncLayout Inflater用于数据绑定的学程便到这里便停止了,愿望趣模板源码网找到的这篇技巧文章能赞助到年夜野,更多技巧学程不妨在站内搜刮。