title: ViewPager having Fragments inside Fragment
body: <p>I am having a little bit hurdle in my application which has a fragment containing a <code>ViewPager</code>. The <code>ViewPager</code> linked with the adapter that also contains a set of fragments. In my application, <code>HomeFragment</code> is the basic fragment. The problem occurs when I run the application everything is working properly but fragments is not loading, only showing <code>ViewPager</code>'s tabs.
  Here I'm sharing my code of base fragment, PageAdapter and fragment_home.xml file. </p>
  
  <p>Here is my parent fragment code: <strong>HomeFragment.java</strong></p>
  
  <pre><code>public class HomeFragment extends Fragment {
  
      Toolbar toolbar;
      TabLayout tabLayout;
      ViewPager viewPager;
      PageAdapter pageAdapter;
      TabItem tabChats;
      TabItem tabStatus;
      TabItem tabCalls;
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saveInstanceState){
          View root= inflater.inflate(R.layout.fragment_home, container, false);
  
          toolbar = (Toolbar)root.findViewById(R.id.toolbar);
          toolbar.setTitle(getResources().getString(R.string.app_name));
          //setSupportActionBar(toolbar);
          tabLayout = (TabLayout)root.findViewById(R.id.tablayout);
          tabChats = (TabItem)root.findViewById(R.id.tabChats);
          tabStatus = (TabItem)root.findViewById(R.id.tabStatus);
          tabCalls = (TabItem)root.findViewById(R.id.tabCalls);
          viewPager = (ViewPager)root.findViewById(R.id.viewPager);
  
          pageAdapter = new PageAdapter(getChildFragmentManager(),tabLayout.getTabCount());
          viewPager.setAdapter(pageAdapter);
          viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
          return root;
      }
  
      @Override
      public void onActivityCreated(@Nullable Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          Handler handler = new Handler();
  
          handler.post(new Runnable() {
              @Override
              public void run() {
                  //------------
              }
          });
      }
  }
  </code></pre>
  
  <p>Here is my page adapter code: <strong>PageAdapter.java</strong></p>
  
  <pre><code>public class PageAdapter extends FragmentPagerAdapter {
  
      private int numOfTabs;
  
      PageAdapter(FragmentManager fm, int tabCount) {
          super(fm);
          this.numOfTabs = numOfTabs;
      }
  
      @Override
      public Fragment getItem(int position) {
          switch (position) {
              case 0:
                  return new ChatFragment();
              case 1:
                  return new StatusFragment();
              case 2:
                  return new CallFragment();
              default:
                  return null;
          }
      }
  
      @Override
      public int getCount() {
          return numOfTabs;
      }
  
  }
  </code></pre>
  
  <p>and here is XML file: <strong>fragment_home.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:layout_height="match_parent"
      xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:background="?attr/colorPrimary"
          android:minHeight="?attr/actionBarSize"
          android:theme="?attr/actionBarTheme"
          app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
          app:theme="@style/ThemeOverlay.AppCompat.Dark" /&gt;
  
      &lt;android.support.design.widget.TabLayout
          android:id="@+id/tablayout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/colorPrimary"
          app:tabSelectedTextColor="@android:color/white"
          app:tabTextColor="@android:color/black"&gt;
  
          &lt;android.support.design.widget.TabItem
              android:id="@+id/tabChats"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Chats" /&gt;
  
          &lt;android.support.design.widget.TabItem
              android:id="@+id/tabStatus"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Status" /&gt;
  
          &lt;android.support.design.widget.TabItem
              android:id="@+id/tabCalls"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Calls" /&gt;
  
      &lt;/android.support.design.widget.TabLayout&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/viewPager"
          android:layout_width="match_parent"
          android:layout_height="wrap_content" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>