title: Why FragmentStateAdapter not work in ViewPager2?
body: <p>Android Studio 3.6</p>
  
  <p>I want in my activity to use 2 fragments inside ViewPager2.</p>
  
  <p>Here my activity:</p>
  
  <pre><code>import androidx.annotation.Nullable;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.viewpager2.widget.ViewPager2;
  public class QRBluetoothSwipeActivity extends AppCompatActivity {
      private ViewPager2 myViewPager2;
      private ViewPagerFragmentAdapter myAdapter;
  
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          // Make sure this is before calling super.onCreate
          setTheme(R.style.AppTheme); // show splash screen
          super.onCreate(savedInstanceState);
          setContentView(R.layout.qr_bluetooth_swipe_activity);
          init();
      }
  
      private void init() {
          myAdapter = new ViewPagerFragmentAdapter(getSupportFragmentManager());
          myAdapter.addFragment(new BluetoothPageFragment());
          myAdapter.addFragment(new QrPageFragment());
          myViewPager2.setOrientation(ViewPager2.ORIENTATION_VERTICAL);
          myViewPager2.setAdapter(myAdapter);
      }
  
  }
  </code></pre>
  
  <p>here ViewPagerFragmentAdapter</p>
  
  <pre><code>import androidx.annotation.NonNull;
  import androidx.fragment.app.Fragment;
  import androidx.fragment.app.FragmentManager;
  import androidx.viewpager2.adapter.FragmentStateAdapter;
  
  import java.util.ArrayList;
  
  public class ViewPagerFragmentAdapter  extends FragmentStateAdapter {
  
      private ArrayList&lt;Fragment&gt; arrayList = new ArrayList&lt;&gt;();
  
      public ViewPagerFragmentAdapter(@NonNull FragmentManager fragmentManager) {
          super(fragmentManager);
      }
  
      @NonNull
      @Override
      public Fragment getItem(int position) {
          return arrayList.get(position);
      }
  
      public void addFragment(Fragment fragment) {
          arrayList.add(fragment);
      }
  
      @Override
      public int getItemCount() {
          return arrayList.size();
      }
  }
  </code></pre>
  
  <p>but I get compile error:</p>
  
  <pre><code>ViewPagerFragmentAdapter is not abstract and does not override abstract method createFragment(int) in FragmentStateAdapter
  </code></pre>
  
  <p>How I can fix this and use <strong>FRAGMENTS</strong> in <strong>ViewPager2</strong> ?</p>
  
  <p>Thanks</p>