Android Activities And Views
Solution 1:
There are no hard and fast rules, but I've got a few personal ones:
I primarily think of how my users will use the back button. In an optimal app, the natural use of "back" to go through Activities is what I aim for. Each time a user might want to use back, that should be a new Activity. Of course, rules are meant to broken and sometimes you'll need to override the back button yourself to control a more complex interface.
Also, you shouldn't be tempted to call setContentView()
again. If you are tempted to redo the entire layout of the page, maybe you should move to a new Activity instead.
I would also check out this guide.
Solution 2:
There should be a rule that says "don't setContentView() twice". As written in Application Fundamentals:
An activity presents a visual user interface for one focused endeavor the user can undertake
So modifying the purpose of a given Activity will actually make you life harder than saving you writing more code.
Post a Comment for "Android Activities And Views"