views:

2097

answers:

2

guys im in deep trouble again... i have 4 Tabs in a TabHost...

let them be A,B,C,D.... now each one is just an index page and clicking on any of them shows a different activity...

The problem is that i need to start another activity wen user selects something from the content displayed in the tab... The other activity should also be displayed in the parent tab itself... is it by any chance possible or i'll have to try some other way around??

Plz... any light on the subject will be useful 4 me... I saw somewhere that its IMPOSSIBLE! Hope that is not the case...

A: 

Can't you change the contentView of your tab instead of starting a new Activity ?

Maybe I'm wrong but I think also that starting an activity in a tab isn't possible because the TabView is hosted in a activity and not the opposite (Tabview don't host an activity per Tab).

kosokund
is there anyway i can erase all the contents and replace them with another layout... it would be helpful if u could give some resource or simple coding...
JaVadid
guess so... so it seems it isnt possible... actually i need to save the state of the previous activities too...
JaVadid
I'm not familiar with tabs, try looking the TabHost javadoc (http://developer.android.com/reference/android/widget/TabHost.html).
kosokund
Well Thomas at last it worked for me by jus changing the ContentView to the new Content i wish to show and processing the data through a common universal Listener... Though it needed very complex bit of coding... and as a matter of fact i haven't completed the coding as i write this... But m sure this is the best method the Tabs can offer...
JaVadid
Happy to read that, more than checking my answer you can also up it to say it was usefull :)
kosokund
+1  A: 

I think the common consensus is that it is best not to use individual Activities as tab content due to these limitations. See these questions and answers for pointers to alternatives:

http://stackoverflow.com/questions/1568739/android-why-shouldnt-i-use-activities-inside-tabs http://stackoverflow.com/questions/1590340/android-tabs-mapview-activities-within-tabs

Jeff Gilfelt