2

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.

Smi
  • 13,850
  • 9
  • 56
  • 64
Aathira
  • 23
  • 3

3 Answers3

4

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>)
FrVaBe
  • 47,963
  • 16
  • 124
  • 157
0

You can use Tabhost.setCurrentTab(number) for this purpose

Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
0

This discussion will help u. In my case GrandPrix's solution helped me.

EDIT:

Go through the follwing links:

Development Guide

Programming Android

Android Development Tutorial (Gigerbread - V 1.3)

Layout Tutorial

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.

Community
  • 1
  • 1
Dijo David
  • 6,175
  • 11
  • 35
  • 46
  • Thanks Dijo .... but i seems to not understand much....can you have any codes with you to explain...am sorry to disturb u...am running out of time here... Aathira – Aathira Mar 25 '11 at 09:53
  • its working !!!!!!!!!! the link provided by you had a solution which i tried out.... you actually saved my project Dijo....thanks for helping me out and sharing the wealthy knoweldge you have shared – Aathira Mar 25 '11 at 10:05
  • Welcome Athira :) Very happy that my link helped you... Dnt 4get to select my ans b4 continuing with the project ;) – Dijo David Mar 25 '11 at 10:16
  • yes its working fine dijo....can you please let me know on layouts used in android if possible...what is also the best way to learn android programing....please share if possible how you studied and how long you have been doing it.....am a trainee in my firm and need to study it as fast as i can..... – Aathira Mar 25 '11 at 10:55
  • Are you from cochin as well... surprised.... Thank you sir for helping me out.... please provide me with all the study materials if you can.....the tabs are working fine..some problem though....looking to that now....application is crashing – Aathira Mar 25 '11 at 11:50
  • @Athira I have updated my answer. Please check my answer for further reference. I guess you r here for the first time, I can't see my answer checked. If you have got the solution for ur question, its better to check the correct answer so that others can also find it helpful. – Dijo David Mar 25 '11 at 12:02
  • @Dijo Your link is helpful but does not provide an answer because you do not mention what solution of the discussion worked for you. Also it is not clear what solution was fetched by Aathira that helped. So probably nobody will benefit from that - also not from your off topic conversation. – FrVaBe Mar 25 '11 at 12:13