BaseQuickAdapter+RecyclerView使用

2017-12-12  本文已影响0人  WorkFamily

public class SubjectContentAdapter extends         BaseQuickAdapter< Object,BaseViewAdapter>{//Object --> 通常是经过序列化的类

private Context context;

private List data;

private Callback callback;

private RecyclerView recyclerView;

public SubjectContentAdapter(List data,Context context,Callback callback){

    super(R.layout.preview_right_item, data);

    this.context= context;

    this.data= data;

    this.callback= callback;

}

@Override

protected void convert(BaseViewHolder baseViewHolder, Book book) {

      String createDate  = book.getCreateDate();

       longtransToDate = DateFormatUtil.transToDate(createDate);//数据,布局文件,组件ID,适配器

        // baseViewHolder.setText(R.id.tv_create_time,createDate);//注意,没有想到可以连着设

        baseViewHolder.setText(R.id.tv_chapter_title,learnsListObj.getChapterTitle())

            .setText(R.id.tv_create_time,"创建时间:"+ DateFormatUtil.timeStampToDay(transToDate));

        recyclerView= (RecyclerView) baseViewHolder.getConvertView().findViewById(R.id.recyclerView);

        recyclerView.setLayoutManager(newLinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,false));

        recyclerView.setAdapter(newPeriodAdapter(mContext, book.getPeriods(), book,callback));

    }

}

上一篇下一篇

猜你喜欢

热点阅读