Well, what I did very quickly here was totally based on example that I pointed out to you in the comment. So, to simplify, I suggest following the beginning of the example in which he mounts the ViewPager
.
Done this, as you will have only one Fragment
but with different data, in the class Screenslidepagefragment add a parameter and the constructor by passing the page number:
private int position;
public ScreenSlidePageFragment(int position) {
this.position = position;
}
In this same class, in onCreateView
you already have the page number and do what needs to be done using the database and etc.
Returning now on the Screenslidepagerarpter, you need to pass the page number on your new constructor, so now its Adapter:
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return new ScreenSlidePageFragment(position);
}
@Override
public int getCount() {
return NUM_PAGES;
}
}
You can do the download of this project I did and test yourself (ignore the project name).
I believe you’re referring to Viewpager, right? You have something to implement on it like multiple pages or simply want to increment this variable?
– Paulo Rodrigues
so, my application has 1 page that I simulate others, not to load too much and by needing 60 pages, I created a single layout, that when the user changes page I increment a global variable that changes all my textviews and button texts according to the information contained in the database. so I wanted to use this Viewpager to increment this variable and so "change the page"
– Joannis
@Joannis, put this information in your question, to make it clear.
– Wakim