title: How to place Admob Native Advanced Ads in recycler view android?
body: <p>I want place the admob native advanced ads in every 3 position of my recycler view in android app.</p>
  <p>I would like to template provided by Admob.</p>
  <p><a href="https://github.com/googleads/googleads-mobile-android-native-templates" rel="nofollow noreferrer">https://github.com/googleads/googleads-mobile-android-native-templates</a></p>
  <p>Here is xml code implementation of native ads</p>
  <pre><code>&lt;com.google.android.ads.nativetemplates.TemplateView
  android:id=&quot;@+id/my_template&quot;
  &lt;!-- this attribute determines which template is used. The other option is
  @layout/gnt_medium_template_view --&gt;
  app:gnt_template_type=&quot;@layout/gnt_small_template_view&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot; /&gt;
  </code></pre>
  <p>Here is Java code implementation of Admob</p>
  <pre><code>   MobileAds.initialize(this, &quot;[_app-id_]&quot;);
     AdLoader adLoader = new AdLoader.Builder(this, &quot;[_ad-unit-id_]&quot;)
   .forUnifiedNativeAd(new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() {
     @Override
     public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) {
        NativeTemplateStyle styles = new
            NativeTemplateStyle.Builder().withMainBackgroundColor(background).build();
  
        TemplateView template = findViewById(R.id.my_template);
        template.setStyles(styles);
        template.setNativeAd(unifiedNativeAd);
  
      }
   })
   .build();
  
    adLoader.loadAd(new AdRequest.Builder().build());
   }
  </code></pre>
  <p><strong>RecyclerView Adapter Class</strong>:</p>
  <pre><code>public class ArticleAdapter extends RecyclerView.Adapter&lt;ArticleAdapter.MyViewHolder&gt;{
  private Context mContext;
  private List&lt;ArticleJson&gt; articleList;
  String titleoflist;
  
  public class MyViewHolder extends RecyclerView.ViewHolder {
      TextView txtTitle,txtDesc,txtStatus,txtColor,txtAuthor;
      LinearLayout linearLayout;
      private ArticleJson m_articleJson;
  
      public MyViewHolder(View view) {
          super(view);
          txtTitle = view.findViewById(R.id.texViewArticleTitle)
          linearLayout = view.findViewById(R.id.article_linearlayout);
      }
  
      public void bindView(final ArticleJson articleJson){
          m_articleJson = articleJson;
          txtTitle.setText(articleJson.getmTitle());
          txtAuthor.setText(titleoflist);
      }
  }
  
  public ArticleAdapter(Context mContext, List&lt;ArticleJson&gt; articleList,String titleoflist) {
      this.mContext = mContext;
      this.articleList = articleList;
      this.titleoflist = titleoflist;
  }
  
  @NonNull
  @Override
  public ArticleAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  
      View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.list_item_article, parent, false);
     return new ArticleAdapter.MyViewHolder(itemView);
  }
  
  @Override
  public void onBindViewHolder(@NonNull ArticleAdapter.MyViewHolder holder, int position) {
  final ArticleJson articleJson = articleList.get(position);
      holder.bindView(articleJson);
      holder.linearLayout.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        //Toast
      }
  });
  }
  
  @Override
  public int getItemCount() {
      return articleList.size();
  }
  }
  </code></pre>