fbsamples/audience-network

Change index of native ad

Closed this issue · 1 comments

I am following the example to load native ads in recyclerview . I want to show ads after every 7 items it is working fine but the problem I am facing is that I can't remove the ad from 0th position. It is always first item in recyclerview . I want the ads to show from 7th item . How do I change its index

In our sample we use the method NativeAdRecyclerAdapter.getItemViewType(int position) to decide whether we want to show an ad or not. If you are using our sample adapter, you can change the logic in this method to something like:

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

or customise it's logic entirely to suit your needs.