VipXrecAdapter.java 1.7 KB
package com.hh.xuetubao.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hh.xuetubao.R;

import java.util.List;

public class VipXrecAdapter extends RecyclerView.Adapter<VipXrecAdapter.ViewHolder> {

    private List<String> mList;
    private Context mContext;

    public VipXrecAdapter(List<String> mList, Context mContext) {
        this.mList = mList;
        this.mContext = mContext;
    }

    @NonNull
    @Override
    public VipXrecAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.xrv_course, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull VipXrecAdapter.ViewHolder holder, final int position) {
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(turnDetail!=null){
                    turnDetail.turnDetail(position);
                }
            }
        });

    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        public ViewHolder(View itemView) {
            super(itemView);
        }
    }

    private TurnDetail turnDetail;

    public void setTurnDetail(TurnDetail turnDetail) {
        this.turnDetail = turnDetail;
    }

    public interface TurnDetail {
        void turnDetail(int position);

    }
}