You must create a Intent
and call StartActivity
with this Intent
. To pass the parameters, use the extras
which act as a value key to store the parameters.
Note that each axml has a Activity
in this example and it would be the simplest way to achieve what you need. It would have how to make everything respond in the same Activity
but I believe that the solution would be more complex to understand.
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace PrimeiraAtividade
{
[Activity (Label = "PrimeiraAtividade", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
SetContentView (Resource.Layout.LayoutUm);
bttn.Click += delegate {
var activity2 = new Intent (this, typeof(Result));
activity2.PutExtra ("parametro1", edt.Text);
StartActivity (ractivity2ess);
};
}
}
}
Segunda Activity:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace SegundaAtividade
{
[Activity (Label = "SegundaAtividade")]
public class Result : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Create your application here
SetContentView (Resource.Layout.LayoutDois);
TextView sm = FindViewById<TextView> (Resource.Id.meu_texto);
sm.Text = Intent.GetStringExtra ("parametro2") ?? "Erro";
}
}
}
PF people tell me how I do to call a new activity(screen) on Xamarin
– Lucas