title: Is there any way to Show Google Admob in Android Recycler View
body: <p>I want to show Ads using google Admob in my app's Main Activity. I have placed all code requires for showing ads by getting help from google-developers site but when I run my app, ads are not displaying. I don't know what is the problem occurring:</p>
  
  <p><code>MainActivity</code>:</p>
  
  <pre><code>import android.content.Context;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.net.ConnectivityManager;
  import android.net.NetworkInfo;
  import android.os.Bundle;
  import android.support.v7.app.AlertDialog;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.google.android.gms.ads.AdRequest;
  import com.google.android.gms.ads.AdView;
  
  public class MainActivity extends AppCompatActivity {
      public RecyclerView mRecyclerView;
      private RecyclerView.Adapter mAdapter;
      private RecyclerView.LayoutManager mLayoutManager;
      private View view;
      private Button button;
  
  
      String[] mDataSet = new String[]{
             "1","2"
      };
  
      String[] data = new String[]{"Sample Activty "
  
      };
      private Context context;
      private Intent sharingIntent;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          AdView mAdView = (AdView) findViewById(R.id.adView);
          AdRequest adRequest = new AdRequest.Builder().build();
          mAdView.loadAd(adRequest);
  
       mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
          mRecyclerView.addOnItemTouchListener(
                  new RecyclerItemClickListener(context, new RecyclerItemClickListener.OnItemClickListener() {
                      @Override
                      public void onItemClick(View view, int position) {
                          // do whatever
                          Toast.makeText(view.getContext(), "position = " + position, Toast.LENGTH_SHORT).show();
  
  }
                          context.startActivity(intent);
                      }
                  })
          );
  
   // use a linear layout manager
          LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
          mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
          mRecyclerView.setLayoutManager(mLayoutManager);
  
          mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getResources()));
  
          // specify an adapter (see also next example)
          mAdapter = new MyAdapter(mDataSet);
          mRecyclerView.setAdapter(mAdapter);
  </code></pre>
  
  <p>And this is <code>MyAdapter.java</code>:</p>
  
  <pre><code>import android.content.Context;
  import android.content.Intent;
  import android.nfc.Tag;
  import android.support.v7.widget.RecyclerView;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.ViewHolder&gt; {
     // private String[] mDataset;
      public String[] mDataset;
      private String mItem;
      private Context context;
  
      AdapterView.OnItemClickListener itemClickListener;
  
      // Provide a reference to the views for each data item
     // Complex data items may need more than one view per item, and
     // you provide access to all the views for a data item in a view holder
     public class ViewHolder extends RecyclerView.ViewHolder  {
         // each data item is just a string in this case
         public TextView mTextView;
         public TextView mFootView;
  
         public ViewHolder(View v) {
             super(v);
            // context = v.getContext();
             mTextView = (TextView) v.findViewById(R.id.firstLine);
            // mFootView= (TextView) v.findViewById(R.id.secondLine);
         }
     }
     // Provide a suitable constructor (depends on the kind of dataset)
     public MyAdapter(String[] myDataset) {
         mDataset = myDataset;
     }
  
     // Create new views (invoked by the layout manager)
     @Override
     public ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) {
         // create a new view
         View v = LayoutInflater.from(parent.getContext())
                 .inflate(R.layout.item_main, parent, false);
         // set the view's size, margins, paddings and layout parameters
         ViewHolder vh = new ViewHolder(v);
         return vh;
  }
     // Replace the contents of a view (invoked by the layout manager)
     @Override
     public void onBindViewHolder(ViewHolder holder, int position) {
         // - get element from your dataset at this position
         // - replace the contents of the view with that element
         holder.mTextView.setText(mDataset[position]);
     }
  
     // Return the size of your dataset (invoked by the layout manager)
     @Override
     public int getItemCount() {
         return mDataset.length;
        // return mDataset.size();
     }
  }
  </code></pre>
  
  <p>And this <code>activity_main.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:ads="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      android:orientation="vertical"
      tools:context=".MainActivity"
      android:background="@drawable/main_redrose"
      &gt;
  
      &lt;!-- A RecyclerView with some commonly used attributes --&gt;
      &lt;android.support.v7.widget.RecyclerView
          android:id="@+id/my_recycler_view"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:scrollbars="vertical"
          android:divider="@drawable/list_divider"/&gt;
  
      &lt;com.google.android.gms.ads.AdView
          android:id="@+id/adView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_alignParentBottom="true"
          ads:adSize="BANNER"
          ads:adUnitId="@string/banner_ad_unit_id"&gt;
      &lt;/com.google.android.gms.ads.AdView&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>