title: Inflate new layout xml for each view - instantiateItem in PagerAdapter
body: <p>So basically i want to populate the pages inside ViewPager with separate XML layouts for each view position. I'm currently doing this by </p>
  
  <pre><code>@Override
      public Object instantiateItem(View container, int position) {
  
          LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(mContext.LAYOUT_INFLATER_SERVICE);
  
          if(position == 0){
          view = inflater.inflate(R.layout.main, null);
          ((ViewPager) container).addView(view, 0);
          }
          if(position == 1){
              view = inflater.inflate(R.layout.main_second, null);
              ((ViewPager) container).addView(view, 0);
          }
          if(position == 2){
              view = inflater.inflate(R.layout.main_third, null);
              ((ViewPager) container).addView(view, 0);
          }
  
          return view;
  }
  </code></pre>
  
  <p>The views are displayed correctly at first, but when i swipe the ViewPager, the Layout is hidden/destroyed. Why is this? Am i doing it the wrong way? please help and correct me.</p>
  
  <p>Thanks.
  Love. Wesley</p>