gpt4 book ai didi

android - 与recyclerview的数据绑定(bind)我需要帮助。找不到root

转载 作者:太空宇宙 更新时间:2023-11-03 10:40:57 25 4
gpt4 key购买 nike

       public class Orderlist_recyclerview_adapter extends    
RecyclerView.Adapter<Orderlist_recyclerview_adapter.MyViewHolder> {

private Context mContext;
private ArrayList<Orderlist_contents_bindingmodel> mUsersList = null;

private LayoutInflater inflater;

public Orderlist_recyclerview_adapter(Context context, ArrayList<Orderlist_contents_bindingmodel> usersList) {
mContext = context;
mUsersList= usersList;
inflater = LayoutInflater.from(mContext);
}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
// View view = inflater.inflate(R.layout.each_row,viewGroup,false);
OrderlistAdapterContentsBinding binding = OrderlistAdapterContentsBinding.inflate(inflater);
MyViewHolder myViewHolder = new MyViewHolder(binding);
return myViewHolder;
}

@Override
public void onBindViewHolder(MyViewHolder myViewHolder, int i) {
Orderlist_contents_bindingmodel user = mUsersList.get(i);
myViewHolder.vBinding.setOrderlist_model(user);
}

@Override
public int getItemCount() {
return mUsersList.size();
}

public class MyViewHolder extends RecyclerView.ViewHolder {
OrderlistAdapterContentsBinding vBinding;
public MyViewHolder(OrderlistAdapterContentsBinding binding) {
**super(binding.getRoot());**here is the error
this.vBinding = binding;
}
}
}

我需要知道如何将 recyclerview 适配器模型与行布局绑定(bind)。

我已经声明了这些东西

<data>
<variable name="orderlist_model" type="anpi.com.propuesta.binding_models.Orderlist_contents_bindingmodel" />
</data>

我有 TextView ,但仍然会出现这样的错误:

  • 未找到 (text=@{..}) 的资源类型
  • 找不到绑定(bind) .getroot

最佳答案

虽然这个问题似乎很久以前就被问过了,但还是发布了这个问题。添加

import android.databinding.ViewDataBinding;

对我有用。

关于android - 与recyclerview的数据绑定(bind)我需要帮助。找不到root,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33937403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com