title: 'No view found for id' exception while adding tabs in dialog - android
body: <p>I have an activity in which I want to show a dialog with 2 tabs. I have the following code on button click which will show the dialog:</p>
  
  <pre><code>Dialog dialog = new Dialog(this);
  
  // select_category is having ViewPager and TabLayout inside of a Framelayout
  dialog.setContentView(R.layout.select_category);
  
  ViewPager objViewPager = (ViewPager) dialog.findViewById(R.id.viewPager);
  
  objViewPager.setAdapter(new MyTabsAdapter(getSupportFragmentManager()));
  TabLayout mTabLayout = (TabLayout) dialog.findViewById(R.id.tabLayout);
  
  mTabLayout.setTabTextColors(getResources().getColorStateList(R.color.tabcolors));    
  mTabLayout.setupWithViewPager(objViewPager);
  dialog.show();
  </code></pre>
  
  <p>Adaper for ViewPager is as,</p>
  
  <pre><code>public class MyTabsAdapter extends FragmentPagerAdapter {
  
      String[] tabs = {"FIRST", "SECOND"};
  
      public MyTabsAdapter(FragmentManager fm) {
          super(fm);
      }
  
      @Override
      public Fragment getItem(int position) {
          switch (position) {
              case 0: {
                  // for now, returning plain fragment for simplicity
                  return new Fragment(); 
              }
  
              case 1: {
                  return new Fragment();
              }
  
              default:
                  return null;
          }
      }
  }
  </code></pre>
  
  <p>select_category.xml is,</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/background"
      android:theme="@style/NoActionBarTheme"&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/viewPager"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="@dimen/view_pager_top_margin"/&gt;
  
      &lt;android.support.design.widget.TabLayout
          android:id="@+id/tabLayout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/primary" /&gt;
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>When I run this code I'm getting IllegalArgumentException as,</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: No view found for id 0x7f0a00da
    (com.myapp:id/viewPager) for fragment Fragment</p>
  </blockquote>
  
  <p>The TabLayout I'm using is from Google's design support library (<code>android.support.design.widget.TabLayout</code>).</p>
  
  <p>I have no idea where I'm getting wrong. Please help!
  Any tutorial / guide suggestion would be appreciated.</p>