Open itgoyo opened 5 years ago
mainVIPCourseAdapter = new MainVIPCourseAdapter(); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRv.setLayoutManager(linearLayoutManager); mRv.setAdapter(mainVIPCourseAdapter);
public class MainVIPCourseAdapter extends RecyclerView.Adapter<MainVIPCourseAdapter.VIPViewHolder> { @Override public VIPViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // View view = View.inflate(mContext, R.layout.adapter_vip_class_main_item, null); View view = LayoutInflater.from(mContext).inflate(R.layout.adapter_vip_class_main_item, parent, false); return new VIPViewHolder(view); } @Override public void onBindViewHolder(VIPViewHolder holder, int position) { if (null != mList) { holder.mTvTime.setText(mList.get(position).getCLASS_TIME()); holder.mTvCourseName.setText("日期:" + date); // 0:待续课 1:已预约 2:续课成功 3:续课失败 4:续课停止 String vip_status = mList.get(position).getVIP_STATUS(); if (vip_status != null) { if (vip_status.equals("0")) { holder.mTvStatus.setText("待续课"); } else if (vip_status.equals("1")) { holder.mTvStatus.setText("已预约"); } else if (vip_status.equals("2")) { holder.mTvStatus.setText("续课成功"); } else if (vip_status.equals("3")) { holder.mTvStatus.setText("续课失败"); } else if (vip_status.equals("4")) { holder.mTvStatus.setText("续课停止"); } } holder.mTvTeacherinfo.setText("老师:" + mList.get(position).getUSER_NAME()); } } @Override public int getItemCount() { return null != mList ? mList.size() : 0; } class VIPViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.tv_time) TextView mTvTime; @BindView(R.id.tv_course_name) TextView mTvCourseName; @BindView(R.id.tv_status) TextView mTvStatus; @BindView(R.id.tv_teacherinfo) TextView mTvTeacherinfo; public VIPViewHolder(View itemView) { super(itemView); ButterKnife.bind(this, itemView); } } }