package com.bw.com.weekzhou.bean;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bw.com.weekzhou.R;
import java.util.List;
public class RecyAdapter extends RecyclerView.Adapter<RecyAdapter.ViewHolder> {
Context context;
List<HomeBean.ResultBean.MlssBean> mlss;
public RecyAdapter(Context context, List<HomeBean.ResultBean.MlssBean> mlss) {
this.context = context;
this.mlss=mlss;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
ViewHolder viewHolder = new ViewHolder(LayoutInflater.from(context).inflate(R.layout.recyview, viewGroup, false));
return viewHolder;
}
//绑定值
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
viewHolder.tv.setText(mlss.get(i).getCommodityList().get(i).getCommodityName());
Glide.with(context).load(mlss.get(i).getCommodityList().get(i).getPrice()).into(viewHolder.imag);
}
@Override
public int getItemCount() {
return mlss.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
private TextView tv;
private ImageView imag;
public ViewHolder(@NonNull View itemView) {
super(itemView);
imag= itemView.findViewById(R.id.iamg);
tv=itemView.findViewById(R.id.text);
}
}
}