Tuesday, July 26, 2011

[android-developers] Is there a way to display fragments in TabHost?

I'd like to show a different fragment in a TabHost, for every tab. But
it seems that there's no easy way to do this. TabHost can only accept
A. Views or B. Intents that launch Activities when the user selects a
tab.

Going with A means that I have to initialize every fragment and load
them into container Views that are given to the TabHost. But I want
these fragments to load only when needed - when the user selects their
tab that is.

Going with B means that I load the fragments into separate Activities
for each tab. But I'd like the fragment to be able to reach the
"original" parent Activity, not just some shell Activity that hosts
them in a tab content.

Am I missing something? Is there a way to manage fragments with
TabHost properly?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment