package com.example.leudaemialikeme.Adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.leudaemialikeme.Model.Question;
import com.example.leudaemialikeme.R;

import java.util.List;

public class QuestionAdapter extends RecyclerView.Adapter<QuestionAdapter.ViewHolder>{
    private List<Question> questionList;

    //重写构造方法
    public QuestionAdapter(List<Question> questionList){
        this.questionList = questionList;
    }
    public int getItemCount(){
        return questionList.size();
    }
    //内部类
    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView questionInfo,questionRead,questionTime;
        LinearLayout questionMore;

        public ViewHolder(@NonNull View itemView){
            super(itemView);
            this.questionInfo = (TextView)itemView.findViewById(R.id.questionInfo);
            this.questionRead = (TextView)itemView.findViewById(R.id.questionRead);
            this.questionTime = (TextView)itemView.findViewById(R.id.questionTime);
            this.questionMore = (LinearLayout) itemView.findViewById(R.id.questionMore);
        }
    }
    //重写 onCreateViewHolder()方法
    @Override
    public QuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.question_item,parent,false);
        QuestionAdapter.ViewHolder holder=new QuestionAdapter.ViewHolder(view);
        return holder;
    }
    //重写onBindViewHolder()方法
    @Override
    public void onBindViewHolder(@NonNull QuestionAdapter.ViewHolder holder, int position){
        Question question = questionList.get(position);
        //TODO
    }
}
