2011-11-22 93 views
0

我有这样的代码,但它让我在哪个Resource.id ....自定义对话框为Android

/Login Customize dialog 
     dialog = new Dialog(this); 
     dialog.SetContentView(Resource.Layout.login); 
     dialog.SetTitle("Sign in to CdcSoftware App"); 
     dialog.SetCancelable(true); 
      //Ok 
      Button btnLogin = FindViewById<Button>(Resource.Id.btnLoginOK); 
      EditText txtUserName = FindViewById<EditText>(Resource.Id.txtUser); 
      TextView txtPassword = FindViewById<TextView>(Resource.Id.txtPassword); 
      //Cancel 
      Button btnCancel = FindViewById<Button>(Resource.Id.btnLoginCancel); 

      dialog.Show(); 

      btnLogin.Click += delegate {Login(txtUserName, txtPassword);}; 
      btnCancel.Click += delegate {Cancel();}; 

private void Login(EditText txtUserName, TextView txtPassword){ 

     Intent intent = Intent; 
     string user = intent.GetStringExtra(txtUserName.ToString()); 
     string password = intent.GetStringExtra(txtPassword.ToString()); 

     var userObject = customers.FirstOrDefault(c => c.CustomerNumber.ToString() == user); 
     if (userObject != null) 
     { 
      Toast.MakeText(this, "User Id doesnt exist", ToastLength.Short).Show(); 
     } 
     if(userObject.CustomerNumber.ToString().ToLower() == user && userObject.CustomerName.ToString().ToLower() == password) 
     { 
      Toast.MakeText(this, "Log in Successfully", ToastLength.Short).Show();  
     } 
     else 
     { 
      Toast.MakeText(this, "User Id or Password is Incorrect", ToastLength.Short).Show(); 
     } 

    } 

我怎么能解决这个问题的错误,以及如何进行互动与此自定义对话框控件主类。

回答

2

我的猜测是你想要的:

Button btnLogin = dialog.FindViewById<Button>(Resource.Id.btnLoginOK); 

代替:

Button btnLogin = FindViewById<Button>(Resource.Id.btnLoginOK); 
+0

是的,我昨天来解决,这是错误,顺便说一句THX。 – arkmetal