2014-01-13 177 views
0

我不能共享2活性之間的數據:Xamarin的數據傳遞活動之間

活性1

homeButton.Click += delegate { 
    var second = new Intent(this, typeof(SecondPage)); 
    second.PutExtra("reg", "qwe"); 
    StartActivity (typeof(SecondPage)); 
    } 

Acitvity2(SecondPage)

string txt = Intent.GetStringExtra ("reg") ?? "null"; 

Console.WriteLine (txt); 

仍然得到空,有什麼建議?

回答

3

一開始,你應該通過您創建的意圖:

homeButton.Click += delegate { 
    var second = new Intent(this, typeof(SecondPage)); 
    second.PutExtra("reg", "qwe"); 
    StartActivity (second); 
    }