title: How to make RecyclerView inside ViewPager
body: <p>I am planning to make a recyclerview inside ViewPager of SlidingTabLayout.. 
  But I keep getting this error E/RecyclerView: No adapter attached; skipping layout</p>
  
  <p>I tried the same recyclerview on other project without SlidingTabLayout and it works.. </p>
  
  <p>Can anyone help me, I am facing this problem for over 3 days now.. </p>
  
  <p>In addition, I already browse through the questions but none of them are helping..</p>
  
  <p>Here's my code, hope you guys can help! Thank you..</p>
  
  <pre><code>public class NatureItem {
  
  private String mName;
  private String mPrice;
  private int imgThumbnail;
  
  public String getName() {
      return mName;
  }
  
  public void setName(String name) {
      this.mName = name;
  }
  
  public int getThumbnail() {
      return imgThumbnail;
  }
  
  public void setThumbnail(int thumbnail) {
      this.imgThumbnail = thumbnail;
  }
  
  public String getPrice() {
      return mPrice;
  }
  
  public void setPrice(String price) {
      this.mPrice = price;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My Adapter </p>
  
  <pre><code>public class CardAdapter extends RecyclerView.Adapter&lt;CardAdapter.ViewHolder&gt;{
  
  List&lt;NatureItem&gt; mItems;
  
  public CardAdapter() {
      super();
      mItems = new ArrayList&lt;&gt;();
      NatureItem nature = new NatureItem();
      nature.setName("Zt Premium 10W-40SN(3F)");
      nature.setThumbnail(R.drawable.a10w403f);
      nature.setPrice("RM00.00");
      mItems.add(nature);
  
      nature = new NatureItem();
      nature.setName("Free Fricition Formula Synthetic 20W-50SN");
      nature.setThumbnail(R.drawable.a20w502);
      nature.setPrice("RM00.00");
      mItems.add(nature);
  
      nature = new NatureItem();
      nature.setThumbnail(R.drawable.fuelbooster);
      nature.setName("Zt Fuel Booster");
      nature.setPrice("RM00.00");
      mItems.add(nature);
  
      nature = new NatureItem();
      nature.setName("Zt Engine Performance");
      nature.setThumbnail(R.drawable.performance);
      nature.setPrice("RM00.00");
      mItems.add(nature);
  
  
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
      View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.recycler_view_card_item, viewGroup, false);
      ViewHolder viewHolder = new ViewHolder(v);
      return viewHolder;
  }
  
  @Override
  public void onBindViewHolder(ViewHolder viewHolder, int i) {
      NatureItem nature = mItems.get(i);
      viewHolder.tvNature.setText(nature.getName());
      viewHolder.imgThumbnail.setImageResource(nature.getThumbnail());
      viewHolder.tvPrice.setText(nature.getPrice());
  
  
  
  }
  
  @Override
  public int getItemCount() {
      return mItems.size();
  }
  
  
  
  class ViewHolder extends RecyclerView.ViewHolder {
  
      public ImageView imgThumbnail;
      public TextView tvNature;
      public TextView tvPrice;
  
      public ViewHolder(View itemView) {
          super(itemView);
          imgThumbnail = (ImageView)itemView.findViewById(R.id.image);
          tvNature = (TextView)itemView.findViewById(R.id.name);
          tvPrice = (TextView)itemView.findViewById(R.id.price);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My ViewPager </p>
  
  <pre><code>public class homepage extends AppCompatActivity {
  
  RecyclerView mRecyclerView;
  RecyclerView.LayoutManager mLayoutManager;
  RecyclerView.Adapter mAdapter;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_homepage);
      mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
      mRecyclerView.setHasFixedSize(true);
  
      mLayoutManager = new LinearLayoutManager(this);
      mRecyclerView.setLayoutManager(mLayoutManager);
  
      mAdapter = new CardAdapter();
      mRecyclerView.setAdapter(mAdapter);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
  
  
  }
  
  }
  </code></pre>
  
  <p>My viewpager called here</p>
  
  <pre><code>public class Tab1 extends Fragment {
  
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      View v =inflater.inflate(R.layout.activity_home,container,false);
      return v;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The XML file (activity_home)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;Button
      android:layout_width="220dp"
      android:layout_height="wrap_content"
      android:text="@string/allproduct_button"
      android:id="@+id/button2"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="10dp"
      android:background="@color/colorAccent"
      android:onClick="onClick"
      android:textColor="#FFFFFF" /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceLarge"
      android:text="@string/BestSellTitle"
      android:id="@+id/textView"
      android:layout_below="@+id/button2"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="10dp" /&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_below="@+id/textView"&gt;
  
  
  &lt;android.support.v7.widget.RecyclerView
      android:id="@+id/recycler_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>