Building a Fragment Pager/slider app
We can put whole fragments as pages in a PagerAdapter
. This is quite powerful because, as we know, a Fragment
can have a large amount of functionality, even a fully-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 the TextView,
however, it should be obvious how we could easily add any layout we have learned so far and then let the user interact with it.
Note
In the next project, we will see yet another way to display multiple Fragment
instances, NavigationView
, and we will actually implement multiple coded Fragment
instances.
The first thing we will do is ...
Get Android Programming for Beginners - Second Edition 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.