小编Roy*_*uez的帖子

在 Xamarin 中的活动之间传递数据

我无法将 MainActivity 中的数据共享到 Welcome 活动,即使我遵循了此页面的说明:https : //developer.xamarin.com/recipes/android/fundamentals/activity/pass_data_between_activity/

主活动(Activity1)

Button button = FindViewById<Button>(Resource.Id.send);
EditText myName = FindViewById<EditText>(Resource.Id.name);
string name = myName.Text;

button.Click += delegate { 
    var welcome = new Intent(this, typeof(Welcome));
    welcome.PutExtra("name", name);
    StartActivity(welcome);
};
Run Code Online (Sandbox Code Playgroud)

欢迎(活动2)

string name = Intent.GetStringExtra("name") ?? "Data not available";
Run Code Online (Sandbox Code Playgroud)

我得到空值,不知道为什么。有什么建议或建议吗?

c# android xamarin

3
推荐指数
1
解决办法
1369
查看次数

标签 统计

android ×1

c# ×1

xamarin ×1