diff --git a/app/src/main/java/com/example/citrusclient/views/MyAdapter.java b/app/src/main/java/com/example/citrusclient/views/MyAdapter.java index 3594317..05b6063 100644 --- a/app/src/main/java/com/example/citrusclient/views/MyAdapter.java +++ b/app/src/main/java/com/example/citrusclient/views/MyAdapter.java @@ -1,11 +1,14 @@ package com.example.citrusclient.views; +import android.app.Activity; +import android.content.Context; import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import com.example.citrusclient.Citrus; import com.example.citrusclient.R; import com.example.citrusclient.models.Book; @@ -40,6 +43,7 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) { Book currentBook = filteredList.get(position); holder.bind(currentBook); // bindメソッドで設定 + Context context = holder.itemView.getContext(); // 背景色の設定 int red, green, blue; @@ -52,13 +56,13 @@ } holder.titleTextView.setBackgroundColor(Color.rgb(red, green, blue)); holder.titleTextView.setTextColor(Color.rgb(255 - red, 255 - green, 255 - blue)); -// holder.titleTextView.setOnClickListener(v -> { -// Activity activity = (Activity) context; -// Citrus citrus = (Citrus) activity.getApplication(); -// citrus.setCurLookingAccountId(currentBook.getAccountId()); -// citrus.setCurLookingBookId(currentBook.getBookId()); -// ((MainActivity) activity).showFragment(new HomeFragment()); -// }); + holder.titleTextView.setOnClickListener(v -> { + Activity activity = (Activity) context; + Citrus citrus = (Citrus) activity.getApplication(); + citrus.setCurLookingAccountId(currentBook.getAccountId()); + citrus.setCurLookingBookId(currentBook.getBookId()); + ((MainActivity) activity).showFragment(new OtherHomeFragment()); + }); } @Override