NativeExpressAdView

public final class NativeExpressAdView extends ViewGroup

The View to display native express ads. The ad size and ad unit ID must be set prior to calling loadAd(AdRequest). Sample code:

 public class MyActivity extends Activity {
     private NativeExpressAdView mNativeExpressAdView;

     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

         LinearLayout layout = new LinearLayout(this);
         layout.setOrientation(LinearLayout.VERTICAL);

         // Create a native express ad. The ad size and ad unit ID must be set before calling
         // loadAd.
         mNativeExpressAdView = new NativeExpressAdView(this);
         mNativeExpressAdView.setAdSize(new AdSize(400, 100));
         mNativeExpressAdView.setAdUnitId("myAdUnitId");

         // Create an ad request.
         AdRequest.Builder adRequestBuilder = new AdRequest.Builder();

         // Optionally populate the ad request builder.
         adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);

         // Add the NativeExpressAdView to the view hierarchy.
         layout.addView(mNativeExpressAdView);

         // Start loading the ad.
         mNativeExpressAdView.loadAd(adRequestBuilder.build());

         setContentView(layout);
     }

     @Override
     public void onResume() {
         super.onResume();

         // Resume the NativeExpressAdView.
         mNativeExpressAdView.resume();
     }

     @Override
     public void onPause() {
         // Pause the NativeExpressAdView.
         mNativeExpressAdView.pause();

         super.onPause();
     }

     @Override
     public void onDestroy() {
         // Destroy the NativeExpressAdView.
         mNativeExpressAdView.destroy();

         super.onDestroy();
     }
 }

XML Attribute Summary

Attribute Name AdsAttrs_adSize AdsAttrs_adUnitId

Inherited Constant Summary

Inherited Field Summary

Public Constructor Summary

NativeExpressAdView(Context context)
Construct a NativeExpressAdView from code.
NativeExpressAdView(Context context, AttributeSet attrs)
Construct a NativeExpressAdView from an XML layout.
NativeExpressAdView(Context context, AttributeSet attrs, int defStyle)
Construct a NativeExpressAdView from an XML layout.

Public Method Summary

void
destroy()
Destroy the ad view.
AdListener