从MainActivity.cs
到AnotherActivity.cs
public static string hisname;
public static string hername;
private Handler mHandler = new Handler();
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Register1);
// Create your application here
EditText her = FindViewById<EditText>(Resource.Id.editTextHername);
EditText his = FindViewById<EditText>(Resource.Id.editTextUrname);
//RotateAnimation anim = new RotateAnimation(0f, 350f, 15f, 15f);
//anim.setInterpolator
//anim.setRepeatCount(Animation.INFINITE);
//anim.Duration(700);
//splash.StartAnimation(anim);
WindowRotationAnimation q = new WindowRotationAnimation();
Button getStarted = FindViewById<Button>(Resource.Id.myButton);
getStarted.Click += delegate
{
var intent = new Intent(this, typeof(CalculateActivity));
intent.PutExtra("yourname", ""+hisname);
intent.PutExtra("GFname", "" + hername);
StartActivity(intent);
};
}
}
答案 0 :(得分:1)
尝试使用以下
var herName = her.text;
vad hisName = his.text;
并添加到intent.putextra
方法。
答案 1 :(得分:1)
public static string hisname;
public static string hername;
private Handler mHandler = new Handler();
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Register1);
// Create your application here
EditText her = FindViewById<EditText>(Resource.Id.editTextHername);
EditText his = FindViewById<EditText>(Resource.Id.editTextUrname);
//RotateAnimation anim = new RotateAnimation(0f, 350f, 15f, 15f);
//anim.setInterpolator
//anim.setRepeatCount(Animation.INFINITE);
//anim.Duration(700);
//splash.StartAnimation(anim);
WindowRotationAnimation q = new WindowRotationAnimation();
Button getStarted = FindViewById<Button>(Resource.Id.myButton);
getStarted.Click += delegate
{
hisname=his.Text;
hername=her.Text;
var intent = new Intent(this, typeof(CalculateActivity));
intent.PutExtra("yourname", hisname);
intent.PutExtra("GFname", hername);
StartActivity(intent);
};
}
inside your OnCreate of the AnotherActivity.cs you can get these strings like this:
string hisname=Intent.GetStringExtra ("yourname");
string hername=Intent.GetStringExtra ("GFname"); // Seriously :P
This is actually an easy solution if you wanted this one. I would suggest you should research first before you post questions
Happy Coding
答案 2 :(得分:0)
将数据从your_first_activity传递到your_next_activity
Intent i = new Intent (Application.Context, typeof(your_next_activity));
i.PutExtra ("item", "item_to_pass");
StartActivity (i);
在your_next_activity
上检索从your_first_activity传递的数据包string item = Intent.GetStringExtra("item");