2016-11-18 77 views
0

我嘗試從後面的代碼更改文本。這是我的代碼設置textview xamarin無法正常工作

TextView txtHome1 = FindViewById<TextView>(Resource.Id.txtHome); 
txtHome1.Text = "Hello"; 
SetContentView(Resource.Layout.Home); 

當我點擊按鈕,將其移動到首頁佈局,txtHome是家庭佈局,我嘗試設置txtHome =「你好」,但cannnot,請幫幫我!

回答

0

您的代碼按錯誤順序排列。 首先設置您的內容視圖,然後編輯文本。

SetContentView(Resource.Layout.Home); 
TextView txtHome1 = FindViewById<TextView>(Resource.Id.txtHome); 
txtHome1.Text = "Hello";