I have a RecyclerView with 10 items. Every item has a TextView and an ImageView.
Let us suppose for item 5, I just want to update the TextView and leave its ImageView as t is, how can we proceed to do it?
I can use notifyItemChanged(int position)
but it will try to refresh the entire layout, which I don't want. Any solution?
CodePudding user response:
It seems you can proceed to use notifyItemChanged(int position)
because it is actually just update the item at the given position
I saw someone explaining about item and structural changes in here, which state that notifyItemChanged(int position)
is actually just change the given item position, rather than notifyDataSetChanged()
which will redraw everything
CodePudding user response:
You can add some logic in onBindViewHolder to just update the TextView:
if (onlyTextViewNeedsUpdate)
// Update TextView
else
// Update all views