I have an activity with a RecyclerView that contains information. I fill out a form, submit it, then the data is entered into Firebase and the Activity displays the item with the data that I entered.
I want to make it so that when I click on any such item, it is copied to a separate table and then I can display it in another Activity. That is, I want to make an Add to Favorites button.
I've tried doing it myself, but I'm stumped.
In the adapter I tried to call the event handler and pass the data from the element I clicked on. But I'm sure this is wrong. And I don't know how to add to Firebase now.
@Override
public void onBindViewHolder(@NonNull CardAdapter.MyViewHolder holder, int position) {
CardData userData = this.cardData.get(position);
holder.favButn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, Favourites.class);
intent.putExtra("id", userData.getId());
intent.putExtra("lastname", userData.getUserLastName());
intent.putExtra("fullName", userData.getUserName());
intent.putExtra("phone", userData.getUserPhone());
intent.putExtra("email", userData.getUserEmail());
v.getContext().startActivity(intent);
}
});
}
If I do that, and if it works, as far as I understand it, there will only be 1 item on the page where I will be redirected after clicking.
But I want to be able to add at least as many items to favorites on one screen (and they wouldn't disappear from here), then go to the Favourites screen and see them there.
How do I do that?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…