protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            btnTranslate = FindViewById <Button>(Resource.Id.btnTranslate);
            txtMessage   = FindViewById <TextView>(Resource.Id.textMessage);
            spinner      = FindViewById <Spinner>(Resource.Id.select_language);



            btnTranslate.Click += BtnTranslate_Click;


            Context context = this;  // Get the Resources object from our context

            res = context.Resources; // Get the string
            Content.Res.Configuration conf = res.Configuration;
            DisplayMetrics            dm   = res.DisplayMetrics;

            conf.SetLocale(new Locale("ak")); //Set local to Akan ak

            res.UpdateConfiguration(conf, dm);

            var lang    = Resources.Configuration.Locale;
            var country = lang.GetDisplayCountry(lang);

            Toast.MakeText(this, "Your current locale is " + lang, ToastLength.Long).Show();
            Toast.MakeText(this, "Country " + country, ToastLength.Long).Show();
            Toast.MakeText(this, "Display Name " + lang.DisplayName, ToastLength.Long).Show();
            Toast.MakeText(this, "Language " + lang.Language, ToastLength.Long).Show();
        }
Exemple #2
0
        ////////////////////////МЕНЮ\\\\\\\\\\\\\\\\\\\\\\


        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            context = Application.Context;
            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(context);
            ISharedPreferencesEditor editor = prefs.Edit();

            languagesId = prefs.GetInt("key_languageId", 1);

            if (languagesId == 1)
            {
                LanguageCodevalue = "en";
            }
            else
            if (languagesId == 2)
            {
                LanguageCodevalue = "fr";
            }
            else
            if (languagesId == 3)
            {
                LanguageCodevalue = "de";
            }
            else
            if (languagesId == 4)
            {
                LanguageCodevalue = "it";
            }
            else
            if (languagesId == 5)
            {
                LanguageCodevalue = "es";
            }
            else
            if (languagesId == 6)
            {
                LanguageCodevalue = "pt";
            }
            else
            if (languagesId == 7)
            {
                LanguageCodevalue = "cs";
            }
            else
            if (languagesId == 8)
            {
                LanguageCodevalue = "pl";
            }
            else
            if (languagesId == 9)
            {
                LanguageCodevalue = "ru";
            }
            else
            if (languagesId == 10)
            {
                LanguageCodevalue = "uk";
            }
            else
            if (languagesId == 11)
            {
                LanguageCodevalue = "ja";
            }
            else
            if (languagesId == 12)
            {
                LanguageCodevalue = "ko";
            }

            Android.Content.Res.Resources res = this.Resources;
            DisplayMetrics Dm = res.DisplayMetrics;

            Android.Content.Res.Configuration conf = res.Configuration;
            if (LanguageCodevalue != null)
            {
                conf.SetLocale(new Locale(LanguageCodevalue));
            }
            else
            {
                conf.SetLocale(new Locale("en"));
            }
            res.UpdateConfiguration(conf, Dm);

            SetContentView(Resource.Layout.Dedoherzer);

            ////////////////////////МЕНЮ\\\\\\\\\\\\\\\\\\\\\\
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id._app_bar);

            SetSupportActionBar(toolbar);
            SupportActionBar.SetTitle(Resource.String.app_name);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.NavigationItemSelected += NavigationView_NavigationItemSelected;
            var drawerToogle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.open_drawer, Resource.String.close_drawer);

            drawerLayout.AddDrawerListener(drawerToogle);
            drawerToogle.SyncState();
            ////////////////////////МЕНЮ\\\\\\\\\\\\\\\\\\\\\\ 

            #region Прив'язка

            switchKMHToMPH       = FindViewById <Switch>(Resource.Id.settingsSwitchKMHToMPH);
            buttonApply          = FindViewById <Button>(Resource.Id.settingsButtonApply);
            languageSpiner       = FindViewById <Spinner>(Resource.Id.languageSpiner);
            firstActivitySpinner = FindViewById <Spinner>(Resource.Id.firstActivitySpiner);

            ButtonReddit      = FindViewById <Button>(Resource.Id.buttonReddit);
            ButtonDiscord     = FindViewById <Button>(Resource.Id.buttonDiscord);
            ButtonEmail       = FindViewById <Button>(Resource.Id.buttonEMail);
            RatingBar         = FindViewById <RatingBar>(Resource.Id.ratingBar);
            ButtonAboutTheApp = FindViewById <Button>(Resource.Id.settingsAboutTheAppButton);

            #endregion

            #region Запам'ятовування перемикача км/г в миль/г

            switchKMHToMPH.Checked = prefs.GetBoolean("key_kmhtomph", false);
            #endregion

            #region Вибір мови

            languages              = LanguageCollection.GetLanguages();
            AdapterLanguage        = new LanguageAdapter(this, languages);
            languageSpiner.Adapter = AdapterLanguage;
            languagesId            = prefs.GetInt("key_languageId", 1);
            languageSpiner.SetSelection(languagesId - 1);  //Автовыбор

            languageSpiner.ItemSelected += LanguageSpiner_ItemSelected;

            #endregion

            #region Вибір актівіті

            firstActivities              = FirstActivityCollection.GetFirstActivitys();
            AdapterFirstActivity         = new FirstActivityAdapter(this, firstActivities);
            firstActivitySpinner.Adapter = AdapterFirstActivity;
            firstActivityId              = prefs.GetInt("key_firstActivityId", 1);

            firstActivitySpinner.ItemSelected += FirstActivitySpinner_ItemSelected;
            #endregion

            #region Кнопка застосувати

            buttonApply.Click += (sender, e) =>
            {
                if (switchKMHToMPH.Checked == true)
                {
                    editor.PutBoolean("key_kmhtomph", true);
                    editor.Apply();
                }
                else
                {
                    editor.PutBoolean("key_kmhtomph", false);
                    editor.Apply();
                }

                if (languagesId == 1)
                {
                    LanguageCodevalue = "en";
                }
                else
                if (languagesId == 2)
                {
                    LanguageCodevalue = "ru";
                }
                if (languagesId == 3)
                {
                    LanguageCodevalue = "uk";
                }
                this.Recreate();
                Toast.MakeText(context, context.Resources.GetString(Resource.String.SettingsApplied), ToastLength.Short).Show();
            };
            #endregion


            ButtonReddit.Click        += ButtonReddit_Click;
            ButtonDiscord.Click       += ButtonDiscord_Click;
            ButtonEmail.Click         += ButtonEmail_Click;
            ButtonAboutTheApp.Click   += ButtonAboutTheApp_Click;
            RatingBar.RatingBarChange += RatingBar_RatingBarChange;
        }