有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在回收器视图中隐藏广告视图

我已经在我的回收商视图中实施了Admob Native Express广告。若并没有可用的互联网,它会在列表中保留空白,直到广告加载。我怎样才能在广告加载之前隐藏空白? 谢谢


共 (1) 个答案

  1. # 1 楼答案

    只需实现一个AdListener来监听onAdLoaded事件

    The onAdLoaded method is executed when an ad has finished loading. If you want to delay adding the AdView to your activity or fragment until you're sure an ad will be loaded, for example, you can do so here. If you're using a third-party analytics package to track impressions, this is also where you can place the call to record one.

    Source

    mAdView.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            // HERE!!!!!!
        }
    });
    

    注意没有必要override all methods

    AdListener provides a default empty implementation for all of its ad lifecycle events. You only need to override the ad events you wish to implement.