title: ViewPager2 error androidx....RecycleView.Adapter) in ViewPager2 can not be applied
body: <p>I converted my old viewPager adapter to the new viewPager2 adapter. 
  I get error when i setAdapter to viewPager2.</p>
  
  <blockquote>
    <p>setAdapter(androidx.viewpager.widget.RecycleView.Adapter) in
    ViewPager2 can not be applied to ViewPagerAdapter</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/RQvDB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RQvDB.png" alt="enter image description here"></a></p>
  
  <p>my <strong>ViewPagerAdapter</strong></p>
  
  <pre><code>public class ViewPagerAdapter extends FragmentStatePagerAdapter {
  
      /**
       * Contains all the fragments.
       */
      private List&lt;Fragment&gt; fragments = new ArrayList&lt;&gt;();
  
      /**
       * Creates a new PagerAdapter instance.
       *
       * @param fragmentManager The FragmentManager.
       */
      public ViewPagerAdapter(FragmentManager fragmentManager) {
          super(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
      }
  
      @Override
      public int getCount() {
          return fragments.size();
      }
  
      @Override
      public Fragment getItem(int position) {
          return fragments.get(position);
      }
  
      /**
       * Adds the fragment to the list, also adds the fragment's tab title.
       *
       * @param fragment New instance of the Fragment to be associated with this tab.
       */
      public void addFragment(Fragment fragment) {
          fragments.add(fragment);
      }
  }
  </code></pre>