I have a ViewPager and a custom PagerAdapter.
In the pager adapter there is a view that onClick
I would like to move to the next page.
I implemented the following:
@Override
public Object instantiateItem(final ViewGroup container, int position) {
view.setOnClickListener(
(view) -> {
int current = ((ViewPager)container).getCurrentItem();
((ViewPager) container).setCurrentItem(current + 1, true);
}
);
}
This works but I am not sure I should be accessing the view pager from inside the adapter like that.
What is the standard way to do this?