1
花了這麼多時間找到這麼簡單的東西后,最後我必須去這裏,需要有人幫助我。在EditText中的getValue - XAMARIN ANDROID
如何從Xamarin中的EditText獲取值,因爲它總是返回null。
這裏是我的代碼:
Button loginBtn;
EditText username;
EditText password;
string user;
string pass;
protected override void OnCreate(Bundle savedInstanceState)
{
RequestWindowFeature(Android.Views.WindowFeatures.NoTitle);
base.OnCreate(savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.LoginForm);
loginBtn = FindViewById<Button>(Resource.Id.login);
username = (EditText)FindViewById(Resource.Id.userName);
password = (EditText)FindViewById(Resource.Id.password);
user = username.Text.ToString();
pass = password.Text.ToString();
loginBtn.Click += (object sender, EventArgs e) =>
{
Toast.MakeText(this, user + " : " + pass, ToastLength.Long).Show();
};
}
謝謝@Yupi,你的建議是正確的。 –