public class NativeAd
extends NativeAdInternal
NativeAd nativeAd = new NativeAd(context, PLACEMENT_ID);
nativeAd.setAdListener(new AdListener() {
public void onAdLoaded(Ad ad) {
if (ad == nativeAd) {
// Renders the ad using creative properties
String adTitle = getAdTitle();
}
}
// rest of AdListener implementation omitted
});
nativeAd.loadAd();
Before displaying the ad, call NativeAd#registerViewForInteraction(View viewContainer)
to handle logging of ad impressions and clicks.
Modifier and Type | Class and Description |
---|---|
static class |
NativeAd.Image
Image creative.
|
static class |
NativeAd.Rating
Rating info.
|
Constructor and Description |
---|
NativeAd(Context context,
String placementId)
Constructs an NativeAd using the given context and placement id.
|
Modifier and Type | Method and Description |
---|---|
static void |
downloadAndDisplayImage(NativeAd.Image image,
ImageView imageView)
Downloads the given Image and displays it in the given ImageView.
|
void |
loadAd() |
public static void downloadAndDisplayImage(NativeAd.Image image, ImageView imageView)
image
- image to be downloadedimageView
- view to show the downloaded imagepublic void loadAd()