Newer
Older
NemophilaClient / app / src / main / java / com / example / nemophila / MyPageActivityAdapter.java
package com.example.nemophila;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class MyPageActivityAdapter extends RecyclerView.Adapter<PostsViewHolder> {

    private List<PostDataModel> list;

    public MyPageActivityAdapter(List<PostDataModel> list) {
        this.list = list;
    }

    @Override
    public PostsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_my_page_activity_posts, parent,false);
        PostsViewHolder vh = new PostsViewHolder(inflate);
        return vh;
    }

    @Override
    public void onBindViewHolder(PostsViewHolder holder, int position) {
        holder.dateView.setText(list.get(position).getDate());
        holder.rateView.setText(list.get(position).getRate());
        holder.genreView.setText(list.get(position).getGenre());
        holder.commentView.setText(list.get(position).getComment());
    }

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