title: ViewPager inside DialogFragment
body: <p>So I know this has been answered multiple times, such as <a href="https://stackoverflow.com/questions/6672066/fragment-inside-fragment/6672688#6672688">Fragment Inside Fragment</a>. I am using the support library for <code>getChildFragmentManager()</code> as advised in the post. The issue is that my viewpager's fragments are not appearing despite being inflated. My tabs (with icons) are showing perfectly fine. Here is the relevant code:</p>
  
  <p>DialogFragment:</p>
  
  <pre><code>public class DialogFragment extends DialogFragment {
  
      private static final String ARG_PAGE = "ARG_PAGE";
  
      private int mPage;
      private HotSpot hotSpot;
      private Gson gson = new Gson();
      private Map nonEmptyPerks;
  
      private TabLayout tabLayout;
      private ViewPager viewPager;
  
      public DialogFragment() {
          // Empty constructor required for DialogFragment
      }
  
      public static PerkDetailDialogFragment newInstance(int page, String hotSpotJson) {
          Bundle args = new Bundle();
          args.putInt(ARG_PAGE, page);
          args.putString("HOTSPOTDETAILED", hotSpotJson);
          PerkDetailDialogFragment fragment = new PerkDetailDialogFragment();
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          mPage = getArguments().getInt(ARG_PAGE);
          String json = getArguments().getString("HOTSPOTDETAILED");
          hotSpot = gson.fromJson(json, HotSpot.class);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_dialog, parent, false);
  
          // Get the ViewPager and set it's PagerAdapter so that it can display items
          viewPager = (ViewPager) view.findViewById(R.id.viewpager);
          tabLayout = (TabLayout) view.findViewById(R.id.perkSelector);
  
          return view;
      }
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState) {
          nonEmptyPerks = getNonEmptyPerks(hotSpot.getPerks());
  
          PerkFragmentPagerAdapter pagerAdapter =
                  new PerkFragmentPagerAdapter(getChildFragmentManager(), nonEmptyPerks.size());
          viewPager.setAdapter(pagerAdapter);
          // Give the TabLayout the ViewPager
          tabLayout.setupWithViewPager(viewPager);
  
          // ..... More code here
      }
  
      @Override
      public void onStart() {
          super.onStart();
          getDialog().getWindow().setLayout(
                  RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
      }
  
      public class PerkFragmentPagerAdapter extends FragmentPagerAdapter {
          private int pageCount;
  
  
          public PerkFragmentPagerAdapter(FragmentManager fm, int pageCount) {
              super(fm);
              this.pageCount = pageCount;
          }
  
          @Override
          public int getCount() {
              return pageCount;
          }
  
          @Override
          public Fragment getItem(int position) {
              String perk = "temp";
  
              return PerkFragment.newInstance(position + 1, perk);
          }
      }
  }
  </code></pre>
  
  <p>PerkFragment:</p>
  
  <pre><code>public class PerkFragment extends Fragment {
  
      private static final String ARG_PAGE = "ARG_PAGE";
      private static final String ARG_PERK_DESCRIPTION = "PERK_DESCRIPTION";
  
      private int mPage;
      private String perkDescription;
  
      public static PerkFragment newInstance(int page, String perk) {
          Bundle args = new Bundle();
          args.putInt(ARG_PAGE, page);
          args.putString(ARG_PERK_DESCRIPTION, perk);
          PerkFragment fragment = new PerkFragment();
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          mPage = getArguments().getInt(ARG_PAGE);
          perkDescription = getArguments().getString(ARG_PERK_DESCRIPTION);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_perk, container, false);
          TextView perkDescriptionTextView = (TextView) view.findViewById(R.id.perkDescription);
          perkDescriptionTextView.setText(perkDescription);
          return view;
      }
  }
  </code></pre>
  
  <p>fragment_dialog.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;ImageView
          android:id="@+id/hotSpotImg"
          android:layout_width="match_parent"
          android:layout_height="250dp"
          android:scaleType="centerCrop"
          android:src="@drawable/img_venue_placeholder" /&gt;
  
      &lt;ImageView
          android:id="@+id/iconBackArrow"
          android:layout_width="50dp"
          android:layout_height="60dp"
          android:layout_alignStart="@+id/hotSpotImg"
          android:layout_alignTop="@+id/hotSpotImg"
          android:src="@drawable/img_back_arrow_shadow" /&gt;
  
      &lt;ImageView
          android:id="@+id/iconGPS"
          android:layout_width="50dp"
          android:layout_height="60dp"
          android:layout_alignBottom="@+id/hotSpotImg"
          android:layout_alignStart="@+id/hotSpotImg"
          android:src="@drawable/img_gps" /&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_below="@+id/hotSpotImg"&gt;
  
          &lt;TextView
              android:id="@+id/memberSpace"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:layout_marginBottom="10dp"
              android:layout_marginTop="10dp"
              android:text="@string/member_space"
              android:textAllCaps="true"
              android:textColor="@color/grey_2"
              android:textSize="16sp" /&gt;
  
          &lt;com.test.test.helpers.LetterSpacingTextView
              android:id="@+id/hotSpotName"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="@+id/memberSpace"
              android:layout_centerHorizontal="true"
              android:layout_marginBottom="10dp"
              android:text="That filler info"
              android:textAlignment="center"
              android:textAllCaps="true"
              android:textColor="@color/black"
              android:textSize="22sp" /&gt;
  
          &lt;android.support.design.widget.TabLayout
              android:id="@+id/perkSelector"
              style="@style/MyCustomTabLayout"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_below="@id/hotSpotName"
              android:layout_marginBottom="10dp"
              app:tabGravity="center" /&gt;
  
          &lt;android.support.v4.view.ViewPager
              android:id="@+id/viewpager"
              android:layout_width="match_parent"
              android:layout_height="0dp" /&gt;
  
          &lt;ScrollView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_above="@+id/checkIn"
              android:layout_below="@id/perkSelector"
              android:layout_centerHorizontal="true"&gt;
  
              &lt;RelativeLayout
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:paddingEnd="20dp"
                  android:paddingStart="20dp"&gt;
  
                  &lt;TextView
                      android:id="@+id/hotSpotHours"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_centerHorizontal="true"
                      android:layout_marginTop="20dp"
                      android:text="@string/hours"
                      android:textColor="@color/grey"
                      android:textSize="14sp" /&gt;
  
                  &lt;TextView
                      android:id="@+id/hotSpotDescription"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_below="@+id/hotSpotHours"
                      android:layout_marginTop="20dp"
                      android:lineSpacingExtra="10dp"
                      android:text="FILLER DESCRIPTION"
                      android:textAlignment="center"
                      android:textColor="@color/grey"
                      android:textSize="16sp" /&gt;
              &lt;/RelativeLayout&gt;
          &lt;/ScrollView&gt;
  
          &lt;TextView
              android:id="@+id/checkIn"
              android:layout_width="200dp"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_centerHorizontal="true"
              android:layout_marginBottom="10dp"
              android:layout_marginTop="10dp"
              android:background="@drawable/text_view_button"
              android:clickable="true"
              android:text="@string/check_in"
              android:textAlignment="center"
              android:textAllCaps="true" /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>fragment_perk.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/perkDescription"
      style="@style/MyCustomTextAppearance"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="PERK FILLER"
      android:textColor="@color/magnises_grey"
      android:textSize="18sp" /&gt;
  </code></pre>