101: Multiple Layouts, Activities or both?

darkuni

Member
Licensed User
Longtime User
Brand new here - and I'm positive this has been answered before, but I'm just not searching right.

My question is simply: when do you use multiple layouts vs multiple activities? And why?

I'm working on a demo app. Essentially it has 4 parts:

1) Intro screen
2) Login screen
3) Listview of results from a database
4) Detailed view of what they clicked in the listview in #3

... and possibly the viewing of a PDF (which would be system level stuff - with their default app).

Currently, I have #3 above working the way I like. I tried wiring layouts to swap between each other - but they seem to end up putting each other atop of one another. That got me thinking about this question.

I want it to work like every other app. On the intro screen, you click START and the screen slides off to the left and the login screen slides in from the right. When you log in, a progress dialog shows up, then it shifts off and the listview slides into place, etc.

Based on what I know thus far, it seems that I could use a single activity with multiple layouts (provided I could get the old one to disappear :) of course). But to get it to behave like other apps, I would probably have to go with activities.

I'm an old school procedural programming guy. OOP is fairly new (and somewhat foreign to me - which is why this VB.net style developer tool is so great) - my main concern would be saving variable state between activities (I haven't even researched that yet).

Again, sorry - I'm sure this is very common and there is a ton of literature for me to read ... just point me in the right direction :)

Thanks!
 

NJDude

Expert
Licensed User
Longtime User
when do you use multiple layouts vs multiple activities? And why?

Multiple layouts implies the use of PANELS which can reside on 1 activity, you will have to manage the visibility of those panels to display the desired layout, depending on your programming habits and the complexity of your app this solution might become a little crazy, on the other hand, multiple activities might be a better solution because you will have one piece of the app isolated on each activity, but, you will have to manage the variables to make them accessible among all the activities, in short, depends on the complexity of your app to decide which solution is the best for you, both solutions have their pros and cons so it comes down to which way you feel more comfortable working with.
 
Upvote 0

darkuni

Member
Licensed User
Longtime User
Thank you .. I just ran across PANELS in one of the demos - and now it's starting to make a little more sense (especially with your write up too).

I think for this "proof of concept" app I'm working on, multiple activities would do nicely. There isn't much data to move between them.

If anyone else has thoughts on the OP, then please chime in! I want to learn all I can! :)
 
Upvote 0

COBRASoft

Active Member
Licensed User
Longtime User
I was convinced multiple activities was the way to go. But, since some weeks I'm working on a bigger app with smooth anims between the 'screens'. To achieve this, I use panels instead of activities. It allows me to animate how I want, when I want and what I want. E.g. I have a header and footer panel that I can keep visible while sliding other panels from the sides. I can remove the header and/or footer when they are not needed for a specific view by sliding them up/down as wanted.

1 hint for a similar approach, place your panels at 200%x so they are not visible. Organize your animations. I have a 'anim in' and 'anim out' object for each panel to keep things easy. I don't use the 'visible = False' and 'Visible = True' because I've read this can give undesired results on Android.
 
Upvote 0

darkuni

Member
Licensed User
Longtime User
I saw the various Animation posts about dealing with custom transitions.

Most of what I'll be doing is Line of Business stuff. They like "cool" but not "OMG C00L!!!!" ... :)

I do appreciate the input. Perhaps I'll strike out and do something cool like that after my feet are fully wet. :)
 
Upvote 0

COBRASoft

Active Member
Licensed User
Longtime User
My app is only for LOB. This doesn't mean you can't add some smooth anims to it. Users expect smoothness nowadays, certainly on mobile apps. It has to be fluent and self-explaining. E.g. I use a slide anim from right to center in about 250ms. This is not disturbing the user, but it has an eye-catching event. Just before the slide, I clear the scrollview, so for the user it seems to be a new panel showing up with a new search function.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Any chance you could post a sample-project showing these sliding panels and your technique?

1 hint for a similar approach, place your panels at 200%x so they are not visible. Organize your animations. I have a 'anim in' and 'anim out' object for each panel to keep things easy. I don't use the 'visible = False' and 'Visible = True' because I've read this can give undesired results on Android.
 
Upvote 0
Top