0
How to make a function for when to click "Back" on Android
in Xamarin
, the app goes back to the previous screen ?
0
How to make a function for when to click "Back" on Android
in Xamarin
, the app goes back to the previous screen ?
1
On any Page, you can overwrite this method
protected override bool OnBackButtonPressed()
{
return base.OnBackButtonPressed();
}
1
Talking about Xamarin.Forms by "Cross Platform Xamarin", you must use the OnBackButtonPressed
. But remembering as it says in the documentation:
The event is generated when the 'back' hardware button is pressed. This event is not generated on iOS.
Just replace this event on your Navigationpage and you’re ready to go:
protected override bool OnBackButtonPressed()
{
// A mágica acontece aqui
return true;
}
I have a main View that when clicking a button goes to the view I’m moving, then in case I need that when I click the back, go back to the previous view to mine, got it ? Only this way is not coming back to her. It closes the app
Browser other questions tagged c# xamarin cross-platform
You are not signed in. Login or sign up in order to post.
it’s still not coming back, it’s like, I have a main view that when Click a button goes to the view I’m moving, then in case I need that when I click the back, go back to the previous view to mine
– AndreeH
Show me your button event. If you’re using Pushasync for the new Page, it will automatically return when you click the Backbutton, you don’t even need to specify an event for this.
– Marlon Ribeiro
Ah, I’m not using Pushasync. I’ll take the test.
– AndreeH
Are you doing how? Setting up Mainpage?
– Marlon Ribeiro
Do so, arrow the Mainpage as a Navigationpage (Your first page). Then on your button click you put Navigation.Pushasync (Your second page)
– Marlon Ribeiro
That @Marlon Ribeiro
– AndreeH
it worked!! That’s right. Thank you.
– AndreeH
Cool! Take a look at this post here that you will understand how the navigation works in Xamarin Forms. https://developer.xamarin.com/guides/xamarin-forms/user-interface/navigation/hierarchical/
– Marlon Ribeiro