Example #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button   button         = FindViewById <Button>(Resource.Id.myButton);
            EditText amountEditText = FindViewById <EditText>(Resource.Id.editTextAmount);
            TextView resultTextView = FindViewById <TextView>(Resource.Id.textViewResult);

            button.Click += delegate
            {
                var    converter = new CashConverter.CurrencyConverter(amountEditText.Text);
                string result    = converter.ConvertCurrency();

                if (converter.HasInputError())
                {
                    resultTextView.Text = string.Empty;
                    Toast.MakeText(this, result, ToastLength.Long).Show();
                }
                else
                {
                    resultTextView.Text = result;
                }
            };
        }
Example #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "Button";
            Button.TouchUpInside          += delegate
            {
                var result = new CashConverter.CurrencyConverter(txtAmount.Text);
                lblResult.Text = result.ConvertCurrency();

                if (result.HasInputError())
                {
                    var alertController = UIAlertController.Create("ERROR", result.ConvertCurrency(), UIAlertControllerStyle.Alert);
                    alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    PresentViewController(alertController, true, null);
                }
            };
        }