package com.example.citrusclient.views; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.example.citrusclient.R; import java.util.List; public class MyBookshelfAdapter extends RecyclerView.Adapter<MyBookshelfAdapter.MyBookViewHolder>{ private List<MyBookshelfFragment.RowBook> bookList; MyBookshelfAdapter(List<MyBookshelfFragment.RowBook> book){ this.bookList = book; } @NonNull @Override public MyBookViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.a_book, parent, false); return new MyBookViewHolder(view); } @Override public void onBindViewHolder(@NonNull MyBookViewHolder holder, int position) { MyBookshelfFragment.RowBook bookData = this.bookList.get(position); holder.bookButton.setText(bookData.hogeTitle); } @Override public int getItemCount() { return bookList.size(); } static class MyBookViewHolder extends RecyclerView.ViewHolder{ Button bookButton; public MyBookViewHolder(@NonNull View itemView) { super(itemView); bookButton = itemView.findViewById(R.id.book_button); } } }