Java. Reference the ViewPager from the XML and assign the adapter to it in the MainActivity.java file after constructing the Adapter for the ViewPager. Create an integer array that contains the photos that will be displayed in the ViewPager.