I have one button that I’d like to go back and forth between two pages in a ViewPager. I know how to make a button go to the specific page. I just want the same button to go back to the previous page OnClick. And for them to cycle between just those 2 pages out of 3.
Here’s what I already have.
I’m sure this is very simple to do, but
since I’m still a java noob, any code examples would be fantastic!
settingsButton = (ImageButton) findViewById(R.id.settingsButton);
settingsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPager.setCurrentItem(0, true);
}
});
Thanks!
use ViewPager.getCurrentItem() to get Current item from ViewPager then move it next or Previous as :