Reputation: 63
I have a tabbed activity on Android Studio.I want to open my second tab on startup.How can i do this?
Upvotes: 3
Views: 1519
Reputation: 46
If you are using viewpager then you can simply do
mViewPager.setCurrentItem(n);
where, n = tab
no which you want to open as default.
Since it counts from index 0
so in your case n=1
, so it will be
mViewPager.setCurrentItem(n);
Upvotes: 3
Reputation: 76
If you are using tabHost then you can simply do-
tabHost.setCurrentTab(1);
just after you set the tabHost in onCreate()
Upvotes: 1