ViewPager is a widget in Android's support library v4 that allows the user to swipe through fragments. The setAdapter method is used to connect the ViewPager with a PagerAdapter.
Example:
ViewPager viewPager = findViewById(R.id.viewPager); PagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(pagerAdapter);
In this example, a ViewPager with the id "viewPager" is found in the current layout. A PagerAdapter is created with the getSupportFragmentManager method and set as the adapter for the ViewPager using the setAdapter method.
This code belongs to the android.support.v4.view package library, as indicated by the import statement at the beginning of the code:
import android.support.v4.view.ViewPager;
Java ViewPager.setAdapter - 30 examples found. These are the top rated real world Java examples of android.support.v4.view.ViewPager.setAdapter extracted from open source projects. You can rate examples to help us improve the quality of examples.