无法在xamarin中的android活动之间传递数据

Tro*_*Otl 1 android android-intent xamarin

在所有教程中都是这样的:

Intent newMainActivity = new Intent (this, typeof(Activity2));
newMainActivity.PutExtra ("MyData", hT);
StartActivity(newMainActivity);
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试这样做时,它仍然说"Android.App.Activity.Intent是'属性'但是像'类型'一样使用"
第二行和第三行都可以,但第一行不起作用

Intent newMainActivity = new Intent (this, typeof(Activity2));
Run Code Online (Sandbox Code Playgroud)

和错误;(

Sus*_*ver 7

Android.App.Activity.Intent是一个"属性",所以错误是绝对正确的,但你应该使用" Android.Content.Intent ".

检查你的using部分,你有任何using static陈述吗?如果是这样,请尝试对其进行评论,并确保您Android.Content在使用部分中有:

使用示例:

using Android.Content;
Run Code Online (Sandbox Code Playgroud)

代码示例:

var newMainActivity = new Intent (this, typeof(Activity2));
Run Code Online (Sandbox Code Playgroud)

如果由于命名空间与你正在做的事情混淆而必须完全限定它Activity.Intent,那么:

var newMainActivity = new Android.Content.Intent (this, typeof(Activity2));
Run Code Online (Sandbox Code Playgroud)