Example #1
0
        private void SetSwitch(int id, bool state = false)
        {
            SwitchCompat switchView = optionsView.FindViewById <SwitchCompat>(id);

            switchView.SetOnCheckedChangeListener(this);
            switchView.Checked = state;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:XFGloss.Droid.Renderers.SwitchCompatCellView"/> class.
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="cell">Cell.</param>
        public SwitchCompatCellView(Context context, Cell cell) : base(context, cell)
        {
            var sw = new SwitchCompat(context);

            sw.SetOnCheckedChangeListener(this);

            SetAccessoryView(sw);

            SetImageVisible(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:AiForms.Renderers.Droid.SwitchCellView"/> class.
        /// </summary>
        /// <param name="context">Context.</param>
        /// <param name="cell">Cell.</param>
        public SwitchCellView(Context context, Cell cell) : base(context, cell)
        {
            _switch = new SwitchCompat(context);

            _switch.SetOnCheckedChangeListener(this);
            _switch.Gravity = Android.Views.GravityFlags.Right;

            var switchParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WrapContent,
                ViewGroup.LayoutParams.WrapContent)
            {
            };

            using (switchParam) {
                AccessoryStack.AddView(_switch, switchParam);
            }

            _switch.Focusable      = false;
            Focusable              = false;
            DescendantFocusability = Android.Views.DescendantFocusability.AfterDescendants;
        }