Я загружаю данные из Firebase Firestore и вывожу в RecyclerView. Как сделать onClick для каждого элемента RecyclerView?
Вот мой код:
public class NoteAdapter extends FirestoreRecyclerAdapter<Note, NoteAdapter.NoteHolder> {
public NoteAdapter(@NonNull FirestoreRecyclerOptions<Note> options) {
super(options);
}
@Override
protected void onBindViewHolder(@NonNull NoteHolder holder, int position, @NonNull Note model) {
holder.textViewAmount.setText("");
holder.textViewCoast.setText("");
holder.textViewDate.setText(String.valueOf("");
holder.textViewAmount.setTextColor("");
Glide.with(holder.icon_opt.getContext())
.load(model.getPhoto())
.into(holder.icon_opt);
}
@NonNull
@Override
public NoteHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.note_item,
parent, false);
return new NoteHolder(v);
}
class NoteHolder extends RecyclerView.ViewHolder{
TextView textViewAmount, textViewCoast, textViewDate;
ImageView icon_opt;
CardView Cardview;
public NoteHolder(View itemView) {
super(itemView);
textViewAmount = itemView.findViewById(textAmount);
textViewCoast = itemView.findViewById(textCoast);
icon_opt = itemView.findViewById(R.id.icon_tr);
textViewDate = itemView.findViewById(textDate);
Cardview = itemView.findViewById(cardview);
}
}
}