notifyDataSetChanged后如何避免闪烁效果

问题描述 投票:0回答:2

我已将Google Ads集成到我的应用程序中,当我调用notifyDataSetChnaged时,广告闪烁。

我尝试了以下解决方案-

   fun RecyclerView.disableItemAnimator() {
    var animator: RecyclerView.ItemAnimator? = home_article_recyclerview.getItemAnimator();
    if (animator is SimpleItemAnimator) {
        animator.setSupportsChangeAnimations(false);
    }
}  

 itemAnimator?.changeDuration = 0

但是他们都没有工作。任何帮助,将不胜感激。

android android-recyclerview google-adwords
2个回答
1
投票

您应该使用DiffUtil更新数据。参考:diffUtil


0
投票

您能否尝试使用解决方案一次:myRecyclerView.disableItemAnimator()

© www.soinside.com 2019 - 2024. All rights reserved.