title: How to setup ViewPager and TabLayout with binding?(IllegalArgumentException: No view found)
body: <p>I try to setup a TabLayout and ViewPager with a Fragment by using binding. I get the next exception:</p>
  <blockquote>
  <p>java.lang.IllegalArgumentException: No view found for  0x7f0e007c (com.movies:id/popular_movies_viewpager) for fragment PopularMoviesTabFragment`</p>
  </blockquote>
  <p>My xml files look like these:</p>
  <p><strong>activity_main:</strong></p>
  <pre><code>&lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      tools:context=&quot;com.MainActivity&quot;
      &gt;
  
  &lt;data class=&quot;MainActivityBinding&quot;&gt;&lt;/data&gt;
  
  &lt;RelativeLayout
  
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:id=&quot;@+id/main&quot;&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id=&quot;@+id/popular_movies_viewpager&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;&gt;
  
          &lt;android.support.design.widget.TabLayout
              android:id=&quot;@+id/popular_movies_tablayout&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_gravity=&quot;top&quot; /&gt;
  
      &lt;/android.support.v4.view.ViewPager&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;/layout&gt;
  </code></pre>
  <p><strong>popular_movies_gridview_layout:</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  
  &lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      tools:context=&quot;com.PopularMoviesTabFragment&quot;&gt;
  
  &lt;data&gt;&lt;/data&gt;
  &lt;FrameLayout
  
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
     &gt;
  
      &lt;android.support.v7.widget.RecyclerView
          android:id=&quot;@+id/popular_movies_gridview&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:columnWidth=&quot;600dp&quot;
          android:numColumns=&quot;4&quot;
          android:stretchMode=&quot;columnWidth&quot;
          android:gravity=&quot;left&quot;&gt;
  
      &lt;/android.support.v7.widget.RecyclerView&gt;
  
  &lt;/FrameLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  <p><strong>My MainActivity:</strong></p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private MainActivityBinding binding;
  
      private ViewPager viewPager;
      private TabLayout tabLayout;
      private ViewPagerAdapter viewPagerAdapter;
      
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
  
          binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
  
          viewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager());
          viewPagerAdapter.addFragment(PopularMoviesTabFragment.newInstance(), &quot;Trending&quot;); // this line can cause crashes
          viewPager= binding.popularMoviesViewpager;
          binding.popularMoviesViewpager.setAdapter(viewPagerAdapter);
          binding.popularMoviesTablayout.setupWithViewPager(viewPager);
      }
  }
  </code></pre>
  <p><strong>My Fragment:</strong></p>
  <pre><code>public class PopularMoviesTabFragment extends Fragment {
  
      private List&lt;Movie&gt; movies = new ArrayList&lt;&gt;();
      private PopularMoviesGridviewLayoutBinding binding;
      private PopularMoviesAdapter adapter;
     
    
     public PopularMoviesTabFragment() {
          // Required empty public constructor
      }
      public static PopularMoviesTabFragment newInstance() {
          PopularMoviesTabFragment fragment = new PopularMoviesTabFragment();
          Bundle args = new Bundle();
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          binding = DataBindingUtil.setContentView(getActivity(), R.layout.popular_movies_gridview_layout);
          RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), 3);
          binding.popularMoviesGridview.setLayoutManager(layoutManager);
          .
          .
          .
          .
      }
  </code></pre>
  <p>How should I change my code to be able to avoid the no view for the fragment exception?</p>