I'm trying to get my app to change from tab 1 to tab 3. The tabs are in a custom TabsPagerAdapter
which extends FragmentPagerAdapter
.
I've tried to change the tab likes this but it causes NullPointerException
. Is the mechanism different with a FragmentPagerAdapter
?
TabHost host = (TabHost) getActivity().findViewById(android.R.id.tabhost);
host.setCurrentTab(2);
Got it. Needed to use my ViewPager
instead of TabHost
ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.pager);
viewPager.setCurrentItem(2);
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