1. Download our Official Android App: Forums for Android!

Apps Activity vs Layout

Discussion in 'Android Development' started by safibaba, May 16, 2010.

  1. safibaba

    safibaba Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    15
    Joined:
    May 3, 2010

    May 3, 2010
    15
    0
    15
    I couldn't find any discussion about this anywhere. Just wondering what the 'best practice is'.

    I am making a little game - it has 4 pretty standard screens

    1. Main menu
    2. Game screen
    3. Help screen
    4. Hi scores screen

    So my question is - which is the best approach.

    1. Make each screen a separate activity and launch each one from the main menu activity

    2. Make each screen a layout and change setContentView in the main activity


    I guess a lot rests on the best practice for these things. Like - if you hit the back button on your android device, should a game exit completely, or should it return to the main menu first..so you have to press back twice to exit?
     

    Advertisement

  2. Boogs

    Boogs Well-Known Member
    Rank:
    None
    Points:
    18
    Posts:
    85
    Joined:
    Apr 6, 2010

    Apr 6, 2010
    85
    16
    18
    I would say to encapsulate the classes better you would want to make each a separate activity. Otherwise you're going to have to handle all those functions in one class, not to mention handling all the states statically if the user changes the phone orientation. Better to go with the separate activities...
     
  3. safibaba

    safibaba Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    15
    Joined:
    May 3, 2010

    May 3, 2010
    15
    0
    15
    Thanks for the advice Boogs. I will go that route then.

    I notice that if you call a sub activity, it doesn't get listed separately in the running processes - so that's good. I guess only applications get listed.
     

Share This Page

Loading...