Is there a simple way to clear the layout of an android activity? I am working on an app that currently spans multiple activities and requires keeping track of variables from the different activities to be used in the final activity of my project. I’m just wondering if it’s possible to create everything in one single activity, preform an action, store a variable, and then clear the activity screen and load another layout? It seems much simpler to me than having to keep track of multiple variables across multiple activities.
Share
sure, you can set any content view at any time.
However, this will quickly become unwieldy (believe me I’ve tried) as your activity grows and grows and grows to reflect interaction with what would natively be placed in separate Activities. The better approach is to extend Application and store all your persistant variables in that. Any activity can see the parent Application at any time, and you can count on those variables persisting so long as any Activity is visible. If you need variables to persist through long sleep cycles you’ll want to store those in SharedPreferences, but that’s true no matter HOW you choose to organize your presentation.