Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android NotifyDataSetChange后如何避免闪烁效果_Android_Android Recyclerview_Google Ads Api - Fatal编程技术网

Android NotifyDataSetChange后如何避免闪烁效果

Android NotifyDataSetChange后如何避免闪烁效果,android,android-recyclerview,google-ads-api,Android,Android Recyclerview,Google Ads Api,我已经在我的应用程序中集成了谷歌广告,当我调用NotifyDataSetchManaged时,广告会闪烁 我尝试了以下解决方案- fun RecyclerView.disableItemAnimator() { var animator: RecyclerView.ItemAnimator? = home_article_recyclerview.getItemAnimator(); if (animator is SimpleItemAnimator) {

我已经在我的应用程序中集成了谷歌广告,当我调用NotifyDataSetchManaged时,广告会闪烁

我尝试了以下解决方案-

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


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

您应该使用DiffUtil更新数据。
请参阅:

您是否可以尝试一次解决方案:
myRecyclerView.disableItemAnimator()

对于ArrayAdapter,只有在适配器上使用add()、insert()、remove()和clear()时,notifyDataSetChanged才起作用。请检查此链接,它将帮助您!!!
 itemAnimator?.changeDuration = 0