You should create a Intent
and call StartActivity
with this Intent
. To pass the parameters, use the extras
that act as key-value to store the parameters.
Notice that each axml has a Activity
in this example and would be the simplest way to achieve what you need. I would have to make everything respond in the same Activity
but I think 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);
};
}
}
}
Second 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";
}
}
}