我最近一直在使用数据绑定,并且遇到了该executePendingBindings
方法。该文档几乎没有介绍它,我无法理解它是如何工作的或何时使用它。
许多开发人员在 onBindViewHolder 回调中使用 executePendingBindings,但在使用与否时,我自己在回收器中没有看到任何差异。
有人可以解释为什么在回收站中使用很重要吗?谢谢
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
Customer customer= List.get(position).second;
((CustomerViewHolder)holder).binding.setCustomer (customer)
((CustomerViewHolder)holder).binding.executePendingBindings();
}
Run Code Online (Sandbox Code Playgroud)