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 ...

Get Android Programming for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.