I have a pager with two fragments, each with its own xml. My question is whether it is possible to switch from one fragment to another programmatically and to fire on any listener?
Best Regards
You need to set current item in ViewPager and then you should notify the adapter to make it bring the new Fragment.
ViewPager ViewPager;
FragmentPagerAdapter adapter;
pager.setCurrentItem(2);
adapter.notifyDataSetChanged();
I'm assuming you mean ViewPager. You can toggle between them by using pager.setCurrentItem(index)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With