Suppose I changed the text of button using setText and moved to another activity. Then if I moved to previous activity,how can i maintain all these changes made in the layout?
Suppose I changed the text of button using setText and moved to another activity.
Share
It depends on how you return to the previous activity.
In case you call
finish()to the current one, theonCreate()of the previous activity does not get called. Thus, in case you have made a change some time, when going back thesetContentView()will not get called, thus the layout will be exactly as it was. (except you perform a different action in theonResume())In case you call
startActivity()to return back, it depends on the flags of the intent.In any case, unless an activity is not destroyed (and you do not change it in any way), it maintains its current layout.
Hope this helps!