I'm new with Xamarin and I'm tring to create an Android App.
I have created a 2 Views
related to 2 different Activities
. The first Activity
, name it A
, has a button that launches the second Activity
, name it B
.
B
has an EventHandler
that is connected, in the OnCreate
method, to A
's Event
. The EventHandler
print on console a string, that's it.
if I launch the app and press the A
's button, the B
activity appears. Now, if I press the Back
button the A
Activity appears again, after that I press the button again and the B
Activity appears but this is a new B
Activity istance and not the previous one. I can see that because the OnCreate
method is called twice and because I can see on console that the event is called twice.
If I repeat this many times I can see the same string printed on console repeated many times. I would like to have only one instance of any activity, so I need to change view without creating more istances of one activity that was already created or destroy the B
Activity when the Back
button is pressed.
How can I do that? is it the right way to do it?