So I've searched allot, and after more in depth and reading, I got the ViewPager to work using this answer - How to implement a ViewPager with different Fragments / Layouts But now I cannot link it to my existing layouts.
I already used MainActivity and it has code that displays the time and stuff so I just made the ViewPager activity called Launch activity but within it, you an set the pages to scroll to, like this -
@Override
public Fragment getItem(int pos) {
switch(pos) {
case 0: return FirstFragment.newInstance("FirstFragment, Instance 1");
case 1: return SecondFragment.newInstance("SecondFragment, Instance 1");
case 2: return ThirdFragment.newInstance("ThirdFragment, Instance 1");
case 3: return ThirdFragment.newInstance("ThirdFragment, Instance 2");
case 4: return ThirdFragment.newInstance("ThirdFragment, Instance 3");
default: return ThirdFragment.newInstance("ThirdFragment, Default");
}
}
But when I change FirstFragment or any of the return states to my pre made classes, it doesn't work. Is there anything I have to do to get it to work?
Explained, furthermore.
So I have my application already set up, but I wish to have it better laid out and more organised, instead of having to scroll a billion times. So I would like to link to my ViewPager to all my activities so I can swipe amongst them. But the problem comes upon adding the class (Activity) to the fragments section (Code above). I simply cannot add it to the section. when I do it gives me an error and tells me this - The method newInstance(String) is undefined for the type MainActivity. so I clicked create method, but I dont know what to do in there, all I want to do is simply link my class that contains functions to my viewpager.