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,你的建议是正确的。 –