First time data loaded correct in recyclerview using databinding ,Need to update the recylerview when user type anything in editText , onTextchange getting new list that need to show in recylerview but its showing old list only.
How to implement this using Databing.
代码 - : 在适配器
@Override
public void onBindViewHolder(FoodsAdapter.ViewHolder holder,final int position) {
binding=holder.getBinding();
binding.setAdapter(this);
binding.setActivity(mActivity);
binding.setVariable(BR.food,foodList.get(position));
/* binding.setFood(foodList.get(position));*/
binding.setPosition(position);
binding.executePendingBindings();
}
在RecylerView中设置适配器
binding.rvFood.setAdapter(null);
binding.rvFood.setAdapter(new FoodsAdapter(activity,foodList));
当我在编辑文本中输入任何内容但从背景到前景的正确数据显示时,使用新列表获取旧列表。
答案 0 :(得分:0)