如何使用FirebaseRecyclerAdapter在recyclerview中实现admob native express广告

时间:2017-07-02 19:15:16

标签: android firebase admob firebaseui native-ads

我想知道要使用FirebaseRecyclerAdapter在recyclerview中实施admob原生广告,如果您能够提前做出答案,请详细解答

1 个答案:

答案 0 :(得分:0)

试试这个

在您的观察者类中:

public NativeExpressAdView nativeAdview;

public YourViewHolder(View view) {
    super(view);

    nativeAdview = (NativeExpressAdView) view.findViewById(R.id.nativeAdView);
}

public void loadNativeAd(AdRequest nativeRequest){
    if(nativeAdview != null) {
        nativeAdview.loadAd(nativeRequest);
        nativeAdview.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                super.onAdLoaded();
                nativeAdview.setVisibility(View.VISIBLE);
            }
        });
    }
}

然后从适配器加载:

protected void populateViewHolder(YourViewHolder viewHolder, myModel model, int position) {

       //Native Ads
        viewHolder.loadNativeAd(nativeRequest);