11Using ViewPager

In this chapter, you will create a new activity to host CrimeFragment. This activity’s layout will consist of an instance of ViewPager. Adding a ViewPager to your UI lets users navigate between list items by swiping across the screen to page forward or backward through the crimes.

Figure 11.1  Swiping to page through crimes

Swiping to page through crimes

Figure 11.2 shows an updated diagram for CriminalIntent. The new activity will be named CrimePagerActivity and will take the place of CrimeActivity. Its layout will consist of a ViewPager.

Figure 11.2  Layout diagram for CrimePagerActivity

The only new objects you need to create are within the dashed rectangle ...

Get Android Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.