7

I've read at a few places that I should not be using Activities as contents of my tabs. I would like to know why this is not a recommended approach... Any suggestions?

Legend
  • 113,822
  • 119
  • 272
  • 400
  • This might be why: http://stackoverflow.com/questions/1306689/launching-activities-within-a-tab-in-android – Robert Harvey Oct 14 '09 at 20:24
  • Oh... Thanks... that does sound like a complex requirement. If that isn't the case, am I ok with it? I mean, I would still use activities in the tabs to launch other activities but I don't mind if the activities are launched "outside" the tabs... Any thoughts? – Legend Oct 14 '09 at 20:27
  • Here is a link that may help: **Tabs with Intents**
    [http://www.androidguys.com/2008/12/05/tabs-with-intents/](http://www.androidguys.com/2008/12/05/tabs-with-intents/)
    – Robert Harvey Oct 14 '09 at 20:31

1 Answers1

4

I'd flip it around: why would you want to use activities as tabs? All you do is add overhead and complexity. Just use Views for the tabs.

If you have something that just has to be both a tab and a separate standalone activity, reuse the View.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Actually I was more tempted by your tutorial (posted by Robert in the previous post)... Correct me if I'm wrong, but by using separate intents for the tabs, I will be doing an on-demand loading. So for instance, if there are three listviews, I will be loading just one... Or is it the same if I use Views as well? I am trying to understand the fundamental difference between using either approach... – Legend Oct 14 '09 at 20:36
  • So all I'm seeing is starting one huge activity versus starting an activity on demand... I could be wrong but I'd really appreciate if you can correct me... – Legend Oct 14 '09 at 20:40
  • Thanks a ton! That's exactly the way I was looking for... Just wish Java had partial classes... My main class is growing super huge now... – Legend Oct 15 '09 at 16:05