abdu
abdu

Reputation: 340

how to update a specific item (cardview) in recyclerview OnActivityResult

I have a Fragment inside MainActivty, and inside this Fragment RecyclerView of Articles with cardView (inside this card i have like button and like counter) and when the user click on the cardView will open DetailsActivity that

and I want when onBackPressed to update just this item depends on the data changed (like button and like counter) in DetailsActivity

how to update just this Item ?

sorry for bad English!

Upvotes: 1

Views: 1342

Answers (1)

Priyank Patel
Priyank Patel

Reputation: 12372

First update the data of that specific position item of adapter.

After that call notifyItemChanged(int) to update that specific CardView of RecyclerView

Notify any registered observers that the item at position has changed. Equivalent to calling notifyItemChanged(position, null);

This is an item change event, not a structural change event. It indicates that any reflection of the data at position is out of date and should be updated. The item at position retains the same identity.

Upvotes: 3

Related Questions