I have a login page which has a Advanced button. The button sets a view where a user can add some information. When I click save, it goes back to my main view (loginpage) and all info is cleared?
How can I save the state of the first view when navigating away and then back to it?
Thanks开发者_如何学JAVA
Take a look at the activity lifecycle, described in the activity docs. When an activity goes into the background, as when you start a new activity, it can be deleted and will be recreated when the user goes back to the activity.
Additionally, your view will be recreated when you go through a configuration change, like a change in orientation.
In your case, you probably want to save the state in the onPause() method, and reset it in the onResume() method. One easy way to share state between activities, is via SharedPreferences. See Saving Persistent State for an example.
精彩评论