コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetActionBar(toolbar);
            ActionBar.Title = "MobiCurrency";

            leftSpinner  = FindViewById <Spinner>(Resource.Id.spinnerLeft);
            rightSpinner = FindViewById <Spinner>(Resource.Id.spinnerRight);

            leftSpinner.ItemSelected  += SpinnerItemSelected;
            rightSpinner.ItemSelected += SpinnerItemSelected;

            var spinnerAdapter = ArrayAdapter.CreateFromResource
                                     (this, Resource.Array.currencies, Android.Resource.Layout.SimpleSpinnerItem);

            spinnerAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

            leftSpinner.Adapter  = spinnerAdapter;
            rightSpinner.Adapter = spinnerAdapter;

            fromCurrency              = FindViewById <EditText>(Resource.Id.editTextCurrencyFrom);
            fromCurrency.TextChanged += ConvertCurrency;

            toCurrency = FindViewById <TextView>(Resource.Id.textViewCurrencyTo);

            RetrieveKey();

            CurrencyConverter.rate = CurrencyGetter.GetRate(leftSpinner.SelectedItem.ToString(),
                                                            rightSpinner.SelectedItem.ToString());
        }
コード例 #2
0
        void SpinnerItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            CurrencyConverter.rate = CurrencyGetter.GetRate(leftSpinner.SelectedItem.ToString(),
                                                            rightSpinner.SelectedItem.ToString());

            ConvertCurrency();
        }
コード例 #3
0
 void ConvertCurrency()
 {
     CurrencyGetter.GetRate(leftSpinner.SelectedItem.ToString(), rightSpinner.SelectedItem.ToString());
     toCurrency.Text = (string.IsNullOrEmpty((fromCurrency.Text)) ? "" :
                        CurrencyConverter.ConvertCurrency((fromCurrency.Text)));
 }