I have a tabbed activity on Android Studio.I want to open my second tab on startup.How can i do this?
Asked
Active
Viewed 1,478 times
3
-
This solution solved my problem ; http://stackoverflow.com/questions/30796710/tablayout-tab-selection – metomero Mar 17 '17 at 21:46
2 Answers
3
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);

currarpickt
- 2,290
- 4
- 24
- 39

MAK
- 46
- 3
1
If you are using tabHost then you can simply do-
tabHost.setCurrentTab(1);
just after you set the tabHost in onCreate()

GladiatorAsif
- 76
- 1
- 5
-
no, im not using tabHost, im using standat tabbed activity mechanizm. – metomero Mar 17 '17 at 11:06