Home > Software engineering >  AdChoicesView deprecated in Facebook ads any replacement
AdChoicesView deprecated in Facebook ads any replacement

Time:04-13

AdChoicesView deprecated in Facebook ads any replacement

import com.facebook.ads.AdChoicesView;
  AdChoicesView adChoicesView = new AdChoicesView(context, nativeAd, true);
                    viewHolder.adChoice = adChoicesView;
 viewHolder.nativeadview.addView(adChoicesView, 0);

CodePudding user response:

As per the Facebook documentation for AdChoicesView:

Deprecated.  since 5.1

@Deprecated public class AdChoicesView extends RelativeLayout

Please use AdOptionsView instead. An expandable, clickable ad choices icon. Can be added to a custom NativeAd view to signify ad content.

is replaced with AdOptionsView:

public class AdOptionsView extends com.facebook.ads.internal.api.AdComponentView

A clickable Ad Options icon, which presents the user with options to report and hide an ad. Should be added to Native Ads to present the users with these options.

You can create an AdOptionsView like the below: 

AdOptionsView adOptionsView = new AdOptionsView(context, nativeAdBase, nativeAdLayout);  
addView(adOptionsView);

You can define extra params, such as the orientation of the icons in the view and the size of the icons like: 

AdOptionsView adOptionsView = new AdOptionsView(context, nativeAdBase, nativeAdLayout, orientation, iconSizeDp);  
addView(adOptionsView);

To change the colors and the size of the icon:

AdOptionsView adOptionsView = new AdOptionsView(context, nativeAdBase, nativeAdLayout);   
adOptionsView.setIconColor(newColor);  
adOptionsView.setIconSizeDp(newIconSizeDp);  
addView(adOptionsView);

The above Parameters are:

context - The application context.

nativeAdBase - The native ad base.

nativeAdLayout - The native ad layout.

orientation - The orientation you want the icons to be in: horizontal or vertical.

iconSizeDp - The required icon size in dp - this will be converted to pixels.

  • Related