MoPubAdRenderer

public interface MoPubAdRenderer<T extends BaseNativeAd>

An interface for creating ad views and rendering them using ad data. Normally you will use the subclass MoPubStaticNativeAdRenderer with ViewBinder to customize your ad view with your own layout. However, to programmatically create or manage your ad view, you can implement MoPubAdRenderer directly.

Public Methods

public View /createAdView(Context context, ViewGroup parent)

  • Description: Creates a new view to be used as an ad. This method is called when you call MoPubStreamAdPlacer.getAdView(int position, View convertView, ViewGroup parent) and the convertView is null. You must return a valid view. Returns a new ad view.

  • Parameters:

    • context: The context. Useful for creating a view. This is recommended to be an Activity. If you have custom themes defined in your Activity, not passing in that Activity will result in the default Application theme being used when creating the ad view.
    • parent: The parent that the view will eventually be attached to. You might use the parent to determine layout parameters, but should return the view without attaching it to the parent.

public void /renderAdView(View view, T ad)

public boolean /supports(BaseNativeAd nativeAd)

  • Description: Determines if this renderer supports the type of native ad passed in. Returns true if the renderer can render the native ad; false if it cannot.

  • Parameters:

    • nativeAd: The native ad to render.

Last updated March 03, 2020

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2020 MoPub (a division of Twitter, Inc.)