【发布时间】:2013-05-08 11:05:51
【问题描述】:
使用 XamarinStudio 及以下基于教程中示例的代码。这里有问题。
- 测试应用程序时是否需要从项目选项> Android 应用程序生成 AndroidManifest?
为什么即使我生成了 AndroidManifest 也没有数据通过,代码:
---活动一 [活动(标签=“HelloMultiScreen”,MainLauncher = true,图标=“@drawable/icon”)] 公共类FirstActivity:活动 { 整数计数 = 1; protected override void OnCreate(捆绑包) { base.OnCreate(捆绑); //使用Main.axml中创建的UI SetContentView (Resource.Layout.Main); var showSecond = FindViewById (Resource.Id.showSecond); showSecond.Click += (sender, e) => { var second = new Intent(this, typeof(SecondActivity)); second.PutExtra("FirstData", "数据来自 FirstActivity"); StartActivity (typeof(SecondActivity)); }; } } ---活动二 [活动(标签=“第二活动”)] 公共类SecondActivity:活动 { protected override void OnCreate(捆绑包) { base.OnCreate(捆绑); // 在此处创建您的应用程序 SetContentView (Resource.Layout.Second); var label = FindViewById (Resource.Id.screen2Label); label.Text = Intent.GetStringExtra("FirstData") ?? “数据不可用”; } }谢谢
【问题讨论】:
-
您会在标签中看到“数据不可用”还是什么也没有?
-
是的。我得到“数据不可用”
标签: xamarin.android