Native Ads: Google
Integrate native ads (Google)
NativeAdView
private NativeAdView containerView;
private TextView titleView;
private TextView descriptionView;
private MediaView mediaView;
private ImageView iconView;
private TextView advertiserView;
private TextView ctaView;private var containerView: NativeAdView? = null
private var titleView: TextView? = null
private var descriptionView: TextView? = null
private var mediaView: MediaView? = null
private var iconView: ImageView? = null
private var advertiserView: TextView? = null
private var ctaView: TextView? = nullprivate void setupGoogleAd(NativeAdData nativeAd) {
// Title
containerView.setHeadlineView(titleView);
titleView.setText(nativeAd.getTitle());
// Ad Icon
containerView.setIconView(iconView);
loadImage(iconView, nativeAd.getIconUrl());
// Body
containerView.setBodyView(descriptionView);
descriptionView.setText(nativeAd.getDescription());
// MediaView
containerView.setMediaView(mediaView); //Google SDK will fill the passed MediaView automatically
// Advertiser
containerView.setAdvertiserView(advertiserView);
advertiserView.setText(nativeAd.getAdvertiser());
// CallToAction
containerView.setCallToActionView(ctaView);
ctaView.setText(nativeAd.getCallToAction());
nativeAd.attachToLayout(containerView, mediaView, iconView, ctaView);
}Change Native Ad AdChoicesIconPosition
Last updated