In Xamarin Android (NOT Xamarin.Forms), I have 2 views, each with a button.
In MainActivity.cs, I start out with the first view and set an onClick handler for the first button. Clicking that button opens the second view, which is working correctly.
Also in MainActivity.cs, I set an onClick handler for the second button (in the second view). However, clicking that button does nothing -- I even set a breakpoint in the handler but it never fires. I want to add some logic but for now all I want is to navigate back to the first view. Here is the code for setting the handler for the second button...
View v2 = this.LayoutInflater.Inflate(Resource.Layout.view2, null);
Button b2 = v2.FindViewById<Button>(Resource.Id.button2);
b2.Click += b2OnClick;
...and the click handler...
private void b2OnClick(object sender, EventArgs eventArgs)
{
SetContentView(Resource.Layout.view1);
}
I would like to use only MainActivity.cs but if that is not possible, please provide an alternate solution.