Reputation: 7331
I am using a viewpager and two fragments. You can swipe between those fragments. Now, how can I implement a button that simulates this swipe gesture on click. Basically, I want to switch to the other fragment on a button click.
How can I do that?
Upvotes: 1
Views: 460
Reputation: 12181
Just change the current fragment inside the onClickListner of the button you have created:
viewPager.setCurrentItem(n);
Where n is the fragment number in the FragmentPagerAdapter.
Upvotes: 1