title: Admob in a recyclerview
body: <p>I'm trying to add an Admob banner in a recyclerview.</p>
  
  <p>My problem is to initialize the Admob.</p>
  
  <p>I have 2 views: the Adview and the list.xml. Adview has Admob xml banner on it.</p>
  
  <p><strong>Adapter</strong></p>
  
  <pre><code>@Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v;
      if (viewType == ad) {
          ad_act = 1;
          v = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.adview, parent, false);
      }
      else {
          ad_act = 0;
          v = LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.list, parent, false);
      }
      return new ViewHolder(v);
  }
  </code></pre>
  
  <p>I need to initialize the Admob, so I tried to add it in my main activity not in my adapter:</p>
  
  <p><strong>Main Activity inside onCreate:</strong></p>
  
  <pre><code>ViewGroup content = (ViewGroup) findViewById(R.id.content_frame);
  getLayoutInflater().inflate(R.layout.activity_main, content, true);
  
  MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
  mAdView = (AdView) findViewById(R.id.adView);
  AdRequest adRequest = new AdRequest.Builder().build();
  mAdView.loadAd(adRequest);
  </code></pre>
  
  <p>but this gives me a null exception R.id.adView</p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke virtual method 'void
    com.google.android.gms.ads.AdView.loadAd(com.google.android.gms.ads.AdRequest)'
    on a null object reference</p>
  </blockquote>
  
  <p>since I'm not adding the r.layout.adview in the main_activity. Any ideas how can I add it there?</p>