title: ViewPager inside a recyclerview
body: <p>Before marking this as a duplicate i have tried all the solutions but nothing worked. Please go through the question and help me. </p>
  
  <p>I have a recycler view that will have multiple viewPagers and both will scroll individually. I cant seem to implement this. My Code is as follows</p>
  
  <p><strong>RecyclerView Adapter</strong></p>
  
  <pre><code>    public class Adapter extends RecyclerView.Adapter&lt;Adapter.holder&gt; {
  
  
      private final LayoutInflater mLayoutInflater;
      private final Context context;
      private final RecyclerView r;
  
      private OnLoadMoreListener onLoadMoreListener;
  
      ArrayList&lt;ceo&gt; mArray = new ArrayList&lt;&gt;();
      private int heightPixels;
      private int widthPixels;
      MainActivity contextActivity;
      public holder mh;
  
  
      public Adapter(Context mContext, final RecyclerView r,MainActivity conts) {
  
          contextActivity=conts;
  
  
  
          this.r=r;
          context = mContext;
          mLayoutInflater = LayoutInflater.from(mContext);
          r.addOnScrollListener(new RecyclerView.OnScrollListener() {
              @Override
              public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                  super.onScrolled(recyclerView, dx, dy);
                  if (!r.canScrollVertically(1)) {
                      onLoadMoreListener.onLoadMore();
                  }
              }
          });
      }
  
      public void setmArray(ArrayList&lt;ceo&gt; mArray) {
          this.mArray = mArray;
  
          Log.e("This-&gt;", mArray.toString());
          notifyItemRangeChanged(0, mArray.size());
  
      }
  
      @Override
      public holder onCreateViewHolder(ViewGroup viewGroup, int i) {
  
          View v = mLayoutInflater.inflate(R.layout.recycler_custom_photo,viewGroup, false);
          mh = new Adapter.holder(v);
          return mh;
      }
      public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {
          this.onLoadMoreListener = onLoadMoreListener;
      }
  
  
  
  
  
      @Override
      public void onBindViewHolder(holder holder, int i) {
  
          ViewPagerAdapter mp = new ViewPagerAdapter(context,mArray);
          holder.vp.setAdapter(mp);
  
  
       }
  
  
  
  
  
      @Override
      public int getItemCount() {
          return mArray.size();
      }
  
      class holder extends RecyclerView.ViewHolder {
  
  
  
          ViewPager vp;
          public holder(View itemView) {
              super(itemView);
             vp=(ViewPager)itemView.findViewById(R.id.pager);
  
          }
           }
             }
  </code></pre>
  
  <p><strong>View Pager Adapter</strong></p>
  
  <pre><code>    public class ViewPagerAdapter extends PagerAdapter {
  
      ArrayList&lt;ceo&gt; alias=null;
      private boolean tk=true;
      Context mcov;
  
      public ViewPager(Context context,ArrayList&lt;ceo&gt; checkAlias) {
  
          mcov=context;
          this.alias=checkAlias;
      }
  
      @Override
      public int getCount() {
  
          Log.e("Sze",alias.size()+"");
          return alias.size();
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return view ==  object;
      }
  
      public void setNestedIndic(boolean token)
      {
        tk=token;
      }
      public Bitmap decodeFile(File f) {
  
          try {
              //Decode image size
              BitmapFactory.Options o = new BitmapFactory.Options();
              o.inJustDecodeBounds = true;
              BitmapFactory.decodeStream(new FileInputStream(f), null, o);
  
              //The new size we want to scale to
              final int REQUIRED_SIZE = 290;
  
              //Find the correct scale value. It should be the power of 2.
              int scale = 1;
              while (o.outWidth / scale / 2 &gt;= REQUIRED_SIZE &amp;&amp; o.outHeight / scale / 2 &gt;= REQUIRED_SIZE)
                  scale *= 2;
  
              //Decode with inSampleSize
              BitmapFactory.Options o2 = new BitmapFactory.Options();
              o2.inSampleSize = scale;
              return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
          } catch (FileNotFoundException e) {
          }
          return null;
      }
  
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
  
  
          LayoutInflater mlAy = (LayoutInflater) mcov
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View m=mlAy.inflate(R.layout.custom_photo, container, false);
          ImageView mimg=(ImageView)m.findViewById(R.id.mainImageFeed);
          TextView tc=(TextView)m.findViewById(R.id.texr);
              String path=alias.get(position).getPath();
  
  
          Log.e("Pos",""+position);
          tc.setText(position+" ");
  
        container.addView(m);
         return  m;
      }
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
          // Remove viewpager_item.xml from ViewPager
          ((android.support.v4.view.ViewPager) container).removeView((RelativeLayout) object);
  
      }
      }
  </code></pre>
  
  <p><strong>recycler_custom_photo.xml</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
     &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" &gt;
      &lt;android.support.v4.view.ViewPager
      android:id="@+id/pager"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
       &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>custom_photo.xml</strong></p>
  
  <pre><code>      &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:background="#313131"
      android:id="@+id/taken"
      android:layout_height="wrap_content"&gt;
      &lt;ImageView
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:src="@drawable/old"
          android:id="@+id/mainImageFeed"
          android:layout_centerVertical="true"
          android:adjustViewBounds="true"
         /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/texr"
          android:textSize="40dp"
          /&gt;
  
     &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>What changes do i need to make to make these work? Thank You for answering!</p>