是否可以将文本框用户输入数据从activity1传递给activity2? 我试过这个,但它不起作用。
var second = new Intent(this, typeof(SecondPage));
second.PutExtra("reg", "qwe");
StartActivity (second);
感谢您的帮助。
答案 0 :(得分:0)
什么不起作用?您是否在其他活动中获取该信息?
public class SecondPage : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var reg = this.Intent.Extras.GetString("reg");
SetContentView(Resource.Layout.second_layout);
var textView = this.FindViewById<TextView>(Resource.Id.secondText);
textView.Text = reg;
这是布局的XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="55.2dp"
android:id="@+id/secondText" />
</LinearLayout>
答案 1 :(得分:0)
var second = new Intent (this, typeof(SecondPage));
second.PutExtra ("value",i);
StartActivity (second);
在SecondPage活动上:
string Passed_value;
Passed_value = Intent.GetStringExtra ("value");
用于int:
int Passed_value;
Passed_value = Intent.GetIntExtra ("value",0);