コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Settings);
            // Create your application here
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.settingsToolbar);

            SetSupportActionBar(toolbar);
            prefs  = PreferenceManager.GetDefaultSharedPreferences(this);
            editor = prefs.Edit();
            SupportActionBar.Title = "Ustawienia";
            Switch gpsSwitch = FindViewById <Switch>(Resource.Id.gpsSwitch);

            gpsSwitch.Checked = prefs.GetBoolean("settingsNotifications", true);
            ChangeText(gpsSwitch);

            Button logout = FindViewById <Button>(Resource.Id.logOutButton);

            gpsSwitch.CheckedChange += (o, e) =>
            {
                editor.PutBoolean("settingsNotifications", e.IsChecked);
                editor.Apply();
                ChangeText(gpsSwitch);
            };

            logout.Click += async(o, e) =>
            {
                await SQLiteDb.LogOut();

                FinishActivity(0);
                var intent = new Intent(this, typeof(SignInActivity));
                StartActivity(intent);
                Finish();
            };
        }