Search code examples
androidandroid-fragmentstabactivity

Tabbed Fragmented applications should have only one activity?


I develop a tabbed application, and since TabActivity is deprecated, I'm doing it the Fragment way. Now, is that mean that I should have only 1 Activity that will hold the tabs and all the other screens of the application will be Fragment's?

And if the answer is:"Yes, you'll find yourself using just 1 Activity", so where is the modularity part of the fragments?? Fragment cannot be reused in other fragments and there is only 1 Activity, so what's the point of using fragments?

Thanks in advance.


Solution

  • You'll most likely find yourself doing a single Activity which holds a single Fragment. This Fragment will most likely hold a TabHost in order to manage your TabWidget which will be your actual tabs.

    Here's the tutorial I found not so long ago when I was creating an Activity with Tabs using the Fragment approach. It's quite well made and self explanatory.