androidfacebook-audience-network

How to Set Facebook Audience Network Native Ads after Every 6 Items Recycler view(GridView)


I recently Started using Audience network. For Now I'm good at Audience Network Banners and Interstitials. But there is a problem with Native Ads. I want to Show native ads After Every 5 items. But Using this below code from Audience network GitHub sample native ad is displaying in the first item. but i want to show after every 5 items. So Can anyone please guide me to achieve this. Thanks in Advance.

@Override
public int getItemViewType(int position) {
return position % AD_DISPLAY_FREQUENCY == 0 ? AD_TYPE : POST_TYPE;
}

Solution

  • Just change the index value from 0 to 5 or 0 to 6. Try this code

    @Override
    public int getItemViewType(int position) {
        return position % AD_DISPLAY_FREQUENCY == 5 ? AD_TYPE : POST_TYPE;
    
    }