ViewPager viewPager = findViewById(R.id.viewPager); MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), fragmentsList); viewPager.setAdapter(adapter); adapter = viewPager.getAdapter();
ViewPager viewPager = findViewById(R.id.viewPager); FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { // Return the fragment to be displayed at the given position } @Override public int getCount() { // Return the total number of fragments } }; viewPager.setAdapter(adapter); adapter = viewPager.getAdapter();Package library: android.support.v4.view