美文网首页
BaseQuickAdapter+RecyclerView使用

BaseQuickAdapter+RecyclerView使用

作者: WorkFamily | 来源:发表于2017-12-12 11:15 被阅读0次

    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));

        }

    }

    相关文章

      网友评论

          本文标题:BaseQuickAdapter+RecyclerView使用

          本文链接:https://www.haomeiwen.com/subject/qveeixtx.html