tags:

views:

35

answers:

1

Hi,

I want to create an sports application that contains the following.

  • TabHost with three main categories. (News, Tables, live score)
  • The news category will have 2 sub categories. (Team news, league news)
  • Tables will have 3 sub categories. (Table, Stats, Schedule)
  • Live score will just Be a ListActivity.

How should I design this? Should all main categories be separate activities? Should my sub categories be activities or just views?

If my sub categories are views i guess i would have to keep track of which view is the current to update/display the proper information.

Also how do i switch between views? Lets say i want to go from view 1 to 3? Using ViewFlipper i can only go to the next one step at the time.

Thanks!

A: 

Should all main categories be separate activities?

No, since they are all on the screen at one time (single TabHost). At most, you could do it as four activities: one for the TabHost and one for each tab, but I am on record as opposing the use of activities for the contents of tabs.

Should my sub categories be activities or just views?

It is impossible to make them be activities.

If my sub categories are views i guess i would have to keep track of which view is the current to update/display the proper information.

When the data changes, update all affected views.

Also how do i switch between views? Lets say i want to go from view 1 to 3? Using ViewFlipper i can only go to the next one step at the time.

No, you can call setDisplayedChild() to jump to any child of ViewFlipper you wish.

CommonsWare
Thanks! If not using activities as content of the tabs, how would you design an app like this?
Raffe
@Raffe: Use views as the contents of the tabs, just as you use views as the contents of the `ViewFlipper`. See here: http://github.com/commonsguy/cw-android/tree/master/Fancy/Tab/
CommonsWare
I have tried a similar thing before. But it felt like I ended up with one HUGE activity and many views. But maybe this is the way to go.
Raffe
@Raffe: You are welcome to use other classes to help decompose your "one HUGE activity". However, object oriented programming existed long before Android, and so the use of activities in tabs is not the only way to help organize your code into smaller chunks.
CommonsWare