Activity
//数据源
ArrayList<RecyBean.DataBean> list = (ArrayList<RecyBean.DataBean>) recyBean.getData();
//设置给RecyclerView
StaggeredGridLayoutManager manager = new
StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
recy.setLayoutManager(manager);
//设置适配器
MyRecyAdapter myRecyAdapter = new MyRecyAdapter(R.layout.grid_iteam,list);
recy.setAdapter(myRecyAdapter);
适配器
extends BaseQuickAdapter<RecyBean.DataBean,BaseViewHolder>
@Override
protected void convert(BaseViewHolder helper, RecyBean.DataBean item) {
//获取文字
helper.setText(R.id.listtext, item.getNews_title());
//获取图片 记得强转一下helper.getView(R.id.image)
Glide.with(mContext).load(item.getPic_url()).into((ImageView) helper.getView(R.id.listimage));
}