예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            EditText phoneNumberText     = (EditText)FindViewById(Resource.Id.PhoneNumberText);
            TextView translatedPhoneWord = (TextView)FindViewById(Resource.Id.TranslatePhoneWord);
            Button   translateButton     = (Button)FindViewById(Resource.Id.TranslateButton);
            Button   translateHistory    = FindViewById <Button>(Resource.Id.TranslationHistory);

            translateButton.Click += (sender, e) =>
            {
                string translatedNumber = PhoneWordTranslator.ToNumber(phoneNumberText.Text);

                if (string.IsNullOrWhiteSpace(translatedNumber))
                {
                    translatedPhoneWord.Text = string.Empty;
                }
                else
                {
                    translatedPhoneWord.Text = translatedNumber;
                    phoneNumbers.Add(translatedNumber);
                }
            };

            translateHistory.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(TranslationHistoryActivity));
                intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);

                StartActivity(intent);
            };
        }
예제 #2
0
 void OnTranslate(object sender, EventArgs e)
 {
     translatedNumber = PhoneWordTranslator.ToNumber(phoneNumberText.Text);
     if (!string.IsNullOrWhiteSpace(translatedNumber))
     {
         callButton.IsEnabled = true;
         callButton.Text      = "Call " + translatedNumber;
     }
     else
     {
         callButton.IsEnabled = false;
         callButton.Text      = "Call";
     }
 }