So I’ll post what I think is the solution to my problem. After adding a single line to my above code giving the ViewPager
a “random” ID; it managed to fix my problem.
At first I was convinced that setting your own ID is bad practice, but apparently there are legitimate ways of doing this. Namely by creating an ids.xml file and letting the Android ecosystem generate an ID for you. I recommend checking out these SO posts for more information – here and here.
Otherwise, I would recommend just creating an XML file for your layout and getting the ViewPager
in your Activity
(instead of programmatically instantiating it), but ultimately it all depends on what you’re trying to accomplish.