
Android Programming with Kotlin for Beginners
By :

We can put whole Fragment
instances as pages in a PagerAdapter
. This is quite powerful because, as we know, a Fragment
instance 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.
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 build the content for the slider. In this case, of course, the content is an instance of Fragment
. We will build one simple class called SimpleFragment
, and one simple layout called fragment_layout
.
You might think this implies...