diff --git a/app/src/main/java/com/example/citrusclient/views/MyBookshelfAdapter.java b/app/src/main/java/com/example/citrusclient/views/MyBookshelfAdapter.java new file mode 100644 index 0000000..3a9418f --- /dev/null +++ b/app/src/main/java/com/example/citrusclient/views/MyBookshelfAdapter.java @@ -0,0 +1,51 @@ +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{ + + private List bookList; + + MyBookshelfAdapter(List 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); + } + } + +}