Reputation: 23
How do I switch between tabs from within one of the activities that is located inside the tab host? I need to complete the project by tomorrow. My project involves showing 3 tabs with varying content. So please help anyone.
Upvotes: 2
Views: 2491
Reputation: 6195
This discussion will help u. In my case GrandPrix's solution helped me.
EDIT:
Go through the follwing links:
Android Development Tutorial (Gigerbread - V 1.3)
Also there will be having some sample codes in the Android SDK. You can find the code under 'samples' folder. You can install the 'APIDemos' sample package to your emulator to get an idea about almost evey part of the android.
Upvotes: 0
Reputation: 49341
If you added the tabs as activities you can use this code inside a tab child activity
TabActivity main = (TabActivity) getParent(); // get the main 'TabActivity' from a Child (tab)
TabHost tabHost = main.getTabHost(); // get a handle to the TabHost
tabHost.setCurrentTab(<index>)
Upvotes: 4