Ejemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.Register);

            register  = FindViewById <Button>(Resource.Id.regBtnRegister);
            sendCode  = FindViewById <Button>(Resource.Id.regBtnSendcode);
            number    = FindViewById <EditText>(Resource.Id.regEditNumber);
            code      = FindViewById <EditText>(Resource.Id.regEditCode);
            psw       = FindViewById <EditText>(Resource.Id.regEditPassword);
            confirm   = FindViewById <EditText>(Resource.Id.regEditConfirm);
            regLayout = FindViewById <LinearLayout>(Resource.Id.regLayout);
            title     = FindViewById <ImageView>(Resource.Id.TitleReg);

            title.SetImageResource(Resource.Drawable.Cover);

            register.Click += delegate
            {
                if ((number.Text == "") || (code.Text == "") || (psw.Text == "") || (confirm.Text == ""))
                {
                    Toast.MakeText(this, "请输入完整的注册信息!", ToastLength.Short).Show();
                }
                else if (number.Text.Length != 11 || !Regex.IsMatch(number.Text, @"^[+-]?\d*$"))
                {
                    Toast.MakeText(this, "手机号码格式不正确", ToastLength.Short).Show();
                }
                else if ((psw.Text != confirm.Text))
                {
                    Toast.MakeText(this, "两次输入的密码不一致!", ToastLength.Short).Show();
                }
                else if (code.Text != "123456")
                {
                    Toast.MakeText(this, "验证码错误!", ToastLength.Short).Show();
                }
                else
                {
                    string res = RegisterData.Post("http://115.159.145.115/Register.php/", number.Text, psw.Text);
                    if (res == "0")
                    {
                        Toast.MakeText(this, "该号码已被注册!", ToastLength.Short).Show();
                    }
                    else if (res == "1")
                    {
                        Intent ActSuccess = new Intent(this, typeof(RegisterSuccess));
                        StartActivity(ActSuccess);
                    }
                }
            };
            sendCode.Click += delegate
            {
                MyCount mc = new MyCount(this, 60000, 1000);
                mc.Start();
            };
            regLayout.Click += delegate
            {
                Android.Views.InputMethods.InputMethodManager imm = (Android.Views.InputMethods.InputMethodManager)GetSystemService(Context.InputMethodService);
                imm.HideSoftInputFromWindow(number.WindowToken, 0);
                imm.HideSoftInputFromWindow(code.WindowToken, 0);
                imm.HideSoftInputFromWindow(psw.WindowToken, 0);
                imm.HideSoftInputFromWindow(confirm.WindowToken, 0);
            };
        }