package com.example.administrator.zhoukao2_moni_20171209.view.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bumptech.glide.Glide;
import com.example.administrator.zhoukao2_moni_20171209.R;
import com.example.administrator.zhoukao2_moni_20171209.model.bean.ShangPingBean;
import java.util.List;
/**
* Created by Administrator on 2017/12/9.
*/
public class MyAdapter extends RecyclerView.Adapter<SimpleHolder>{
Context context;
List<ShangPingBean.DataBean> list;
public MyAdapter(Context context, List<ShangPingBean.DataBean> list) {
this.context = context;
this.list = list;
}
@Override
public SimpleHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(context).inflate(R.layout.myadapter_layout, parent, false);
SimpleHolder simpleHolder = new SimpleHolder(view);
return simpleHolder;
}
@Override
public void onBindViewHolder(SimpleHolder holder, int position) {
String[] split = list.get(position).getImages().split("\\|");
Glide.with(context)
.load(split[0])
.into(holder.img);
holder.name.setText(list.get(position).getTitle());
holder.price.setText(list.get(position).getPrice()+"");
}
@Override
public int getItemCount() {
return list.size();
}
}
RecyclerView的适配器
最新推荐文章于 2021-12-30 16:54:52 发布