根据教程中的示例使用 XamarinStudio 和以下代码库。这里的问题。
- 测试 App 时是否需要从 Project Option> Android Application 生成 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", "Data from 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") ?? “数据不可用”;
}
}
谢谢