/// <summary> /// Callback for the Updatetoggle /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> private void updateToggleClick(object sender, CompoundButton.CheckedChangeEventArgs e) { Switch s = (Switch)sender; if (s.Checked) { this.RunOnUiThread(delegate { Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#FF8C00") }); Fab2.BackgroundTintList = csl; Toast.MakeText(Android.App.Application.Context, "Location Updates On", ToastLength.Short).Show(); AppConfig.PostUpdates = true; }); } else { this.RunOnUiThread(delegate { Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#303F9F") }); Fab2.BackgroundTintList = csl; Toast.MakeText(Android.App.Application.Context, "Location Updates Off", ToastLength.Short).Show(); AppConfig.PostUpdates = false; }); } }
private void SetFabProperties() { try { if (!string.IsNullOrEmpty(element.FabIcon)) { var resId = GetDrawable(element.FabIcon); actionbutton.SetImageResource(resId); } if (element.FabBackgroundColor != Color.SkyBlue) { Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { element.FabBackgroundColor.ToAndroid() }); actionbutton.BackgroundTintList = csl; } if (element.BarBackgroundColor != Color.Default) { bottombar.BarColor = element.BarBackgroundColor.ToAndroid(); } else { element.BarBackgroundColor = Color.LightBlue; bottombar.BarColor = element.BarBackgroundColor.ToAndroid(); } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void CheckboxPropertyChanged(CheckBox model, String propertyName) { if (propertyName == null || CheckBox.ColorProperty.PropertyName == propertyName) { int[][] states = { new int[] { Android.Resource.Attribute.StateEnabled }, // enabled new int[] { Android.Resource.Attribute.StateEnabled }, // disabled new int[] { Android.Resource.Attribute.StateChecked }, // unchecked new int[] { Android.Resource.Attribute.StatePressed } // pressed }; var checkBoxColor = (int)model.Color.ToAndroid(); int[] colors = { checkBoxColor, checkBoxColor, checkBoxColor, checkBoxColor }; var myList = new Android.Content.Res.ColorStateList(states, colors); Control.ButtonTintList = myList; } }