Prithniraj Nicyone
Prithniraj Nicyone

Reputation: 5111

How to prevent blinking if any of the item is changed in recyclerview

I am working on an android application in which I am showing some data using recyclerview. First time the data is getting shown perfectly. Now the changes should be reflect in list as any value of the item view get changed. I have used notifyDataSetChanged() to notify adapter about changes. The items view are blinking when they get changed, so user get to know about this effect, how to remove this blinking effect. I've tried using notifyItemRangeChanged() but getting the same blinking effect with this one as well. Please let me know if anyone know about this issue.

Thanks a lot in advanced.

Upvotes: 2

Views: 7101

Answers (1)

Tarun Sharma
Tarun Sharma

Reputation: 64

Use the below code, this will disable the animation effect, hope this helps

ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {    
  ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);    
}

Upvotes: 1

Related Questions