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;
}
}
}
我需要知道如何将recyclelerview适配器模型与行布局绑定.
我已经宣布了这些事情
<data>
<variable name="orderlist_model" type="anpi.com.propuesta.binding_models.Orderlist_contents_bindingmodel" />
</data>
我有短信,但这样的错误仍在发生:
>找不到资源类型(text = @ {..})
>绑定.getroot未找到
最佳答案 发布这个即使看起来这个问题很久以前就被问过了.添加
import android.databinding.ViewDataBinding;
为我做了诀窍.