title: replace a container with viewPager
body: <p>I made a navigation drawer, as you know the navigation drawer will have a container where all layouts are inflated.
  I need to have a scrollable tabs on one of the pages. I am having problem with inflating the viewPager layout into the container which is implemented in the following fragment class:</p>
  
  <pre><code>public class Pager extends Fragment {
  
  ViewPager viewPager = null;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      getActivity().setContentView(R.layout.fragment_pager);
      viewPager = (ViewPager) getActivity().findViewById(R.id.pager);
  
      FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
      MyAdapter myAdapter = new MyAdapter(fragmentManager);
      viewPager.setAdapter(myAdapter);
  }
  }
  
  
  class MyAdapter extends FragmentPagerAdapter{
  
  Fragment fragment = null;
  
  public MyAdapter(FragmentManager fm) {
      super(fm);
  }
  
  @Override
  public Fragment getItem(int position) {
  
      switch (position){
          case 0:
              fragment = new MapFragment();
              break;
          case 1:
              fragment = new RegisterRestaurants();
              break;
      }
      return fragment;
  }
  
  @Override
  public int getCount() {
  
      return 2;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>layout fragment_pager:</p>
  
  <pre><code>&lt;android.support.v4.view.ViewPager
  android:id="@+id/container"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  &lt;/android.support.v4.view.ViewPager&gt;
  </code></pre>
  
  <p>Hope someone can help, I browsed the internet and all tutorials were doing it from within a FragmentActivity but in my situation I have to do it inside a Fragment</p>
  
  <p>logcat output:</p>
  
  <pre><code>02-25 00:16:17.814  18197-18197/com.example.famfelimban.mydiet E/AndroidRuntime﹕ FATAL EXCEPTION: main
  java.lang.IllegalArgumentException: No view found for id 0x7f090054 (com.example.famfelimban.mydiet:id/container) for fragment Pager{4329bcb0 #1 id=0x7f090054}
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:939)
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
          at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
          at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
          at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:454)
          at android.os.Handler.handleCallback(Handler.java:730)
          at android.os.Handler.dispatchMessage(Handler.java:92)
          at android.os.Looper.loop(Looper.java:176)
          at android.app.ActivityThread.main(ActivityThread.java:5419)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:525)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>activity_main.xml:</p>
  
  <pre><code>&lt;!-- A DrawerLayout is intended to be used as the top-level content view using     match_parent for both width
  and height to consume the full space available. --&gt;    &lt;android.support.v4.widget.DrawerLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity"&gt;
  
  &lt;!-- As the main content view, the view below consumes the entire
       space available using match_parent in both dimensions. --&gt;
   &lt;FrameLayout android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
  &lt;/FrameLayout&gt;
  
  
  &lt;!-- android:layout_gravity="start" tells DrawerLayout to treat
       this as a sliding drawer on the left side for left-to-right
       languages and on the right side for right-to-left languages.
       If you're not building against API 17 or higher, use
       android:layout_gravity="left" instead. --&gt;
  &lt;!-- The drawer is given a fixed width in dp and extends the full height of
       the container. --&gt;
  &lt;fragment android:id="@+id/navigation_drawer"
      android:layout_width="@dimen/navigation_drawer_width"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      android:name="com.example.famfelimban.mydiet.NavigationDrawerFragment"
      tools:layout="@layout/fragment_navigation_drawer" /&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;'
  </code></pre>