O'Reilly logo

Android Programming for Beginners by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a Fragment pager/slider app

We can put complete Fragments as pages in PagerAdapter. This is quite powerful because as we know, a Fragment can have a lot of functionality, even a full-fledged UI.

To keep the code short and straightforward, we will add a single TextView to each Fragment layout, just to demonstrate that the pager is working. When we see how easy it is to get a reference to TextView, however, it should be clear as to how we could easily add any layout that we have learned about so far and then let the user interact with it.

The first thing we will do is build the content for the slider. In this case, of course, the content is Fragment. We will build one simple class called SimpleFragment and one really simple layout called ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required