从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);
};
}
}发布于 2016-04-07 17:58:18
尝试使用以下命令
var herName = her.text;
vad hisName = his.text;并添加到intent.putextra方法中。
发布于 2016-04-07 18:24:49
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);
};
}在AnotherActivity.cs的OnCreate中,您可以获得如下字符串:
string hisname=Intent.GetStringExtra ("yourname");
string hername=Intent.GetStringExtra ("GFname"); // Seriously :P如果你想要这个,这实际上是一个简单的解决方案。我建议你在发表问题之前先研究一下。
快乐编码
发布于 2016-04-07 18:16:53
将数据从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");https://stackoverflow.com/questions/36471535
复制相似问题