开发者

How to implement multiple screens within an App

I am currently working on an Android App which has different service dimensions, such as " service order", "route planning", "photo gallery" and a central login. so far i implemented each "screen" (and by screen i mean actually the layout of a screen) as a seperate class, which loads a specific layout and handles all listeners and core functionalities such as calling webservices in a thread, receiving answers etc. I am not quite sure if this is the best way to implemnt mulitiple layout-screens.

The Android dev guideline proposes to use single activities for each "screen layout". However I doubt that this is the most effective way of doing things. Since i need information for each "layout" which are retr开发者_Go百科ieved by the central login (here: a user object). Since an activity (as far as i understand) is a seperate thread, the passing and retrieving of information seems not very practical.

I would like to get your oppinions/feedback on that and thanks for any hint or tip.

So far my structure looks like :

  • Activity
    • loads login layout (res/layout/login.xml with setlContentView)
    • depending on buttonclick other resources are loaded and initialized (means listeners are added etc.)

Greets Peter


The dev guidelines recommend that for a reason. It IS the most effective way of doing things. You may complain about having to store your data so it can be passed along from activity to activity, but guess what? You're developing an app for a phone! At any point in time, the phone could ring, forcing the user to switch away from your app. Or the user could just choose to temporarily look at a different app. If your app goes back to square one after switching back and lost all data, the user will be understandably angry.


Don't know if this would be suitable for your app, but another option could be to split off the core data handling into a Service, and have your app be just a UI frontend which communicates with that service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜