protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var exampleCorners     = FindViewById <BootstrapButton>(Resource.Id.bbutton_example_corners);
            var exampleOutline     = FindViewById <BootstrapButton>(Resource.Id.bbutton_example_outline);
            var exampleSize        = FindViewById <BootstrapButton>(Resource.Id.bbutton_example_size);
            var exampleTheme       = FindViewById <BootstrapButton>(Resource.Id.bbutton_example_theme);
            var exampleCustomStyle = FindViewById <BootstrapButton>(Resource.Id.example_bbutton_custom_style);


            // create a custom bootstrap size
            exampleCustomStyle.SetBootstrapSize(DefaultBootstrapSize.Sm);

            // create a Bootstrap Theme with holo colors
            exampleCustomStyle.BootstrapBrand = new CustomBootstrapStyle(this);


            exampleCorners.SetOnClickListener(new ViewOnClick(v => { exampleCorners.Rounded = !exampleCorners.Rounded; }));
            exampleOutline.SetOnClickListener(new ViewOnClick(v => { exampleOutline.ShowOutline = !exampleOutline.ShowOutline; }));
            exampleSize.SetOnClickListener(new ViewOnClick(v =>
            {
                size = size.ChangeBootstrapSize();
                exampleSize.SetBootstrapSize(size);
            }));
            exampleTheme.SetOnClickListener(new ViewOnClick(v =>
            {
                exampleTheme.ChangeBootstrapBrand();
            }));
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var changeEnabled = FindViewById <BootstrapEditText>(Resource.Id.bedit_text_change_enabled);
            var changeRound   = FindViewById <BootstrapEditText>(Resource.Id.bedit_text_change_round);
            var changeTheme   = FindViewById <BootstrapEditText>(Resource.Id.bedit_text_change_theme);
            var sizeExample   = FindViewById <BootstrapEditText>(Resource.Id.bedit_text_change_size);

            FindViewById <Button>(Resource.Id.bedit_text_change_enabled_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                changeEnabled.Enabled = !changeEnabled.Enabled;
            }));
            FindViewById <Button>(Resource.Id.bedit_text_change_round_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                changeRound.Rounded = !changeRound.Rounded;
            }));
            FindViewById <Button>(Resource.Id.bedit_text_change_theme_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                changeTheme.ChangeBootstrapBrand();
            }));
            FindViewById <Button>(Resource.Id.bedit_text_change_size_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                size = size.ChangeBootstrapSize();

                sizeExample.SetBootstrapSize(size);
            }));
        }
        public static DefaultBootstrapSize ChangeBootstrapSize(this DefaultBootstrapSize size)
        {
            if (size == null)
            {
                throw new ArgumentNullException(nameof(size));
            }

            if (size == DefaultBootstrapSize.Xs)
            {
                size = DefaultBootstrapSize.Sm;
            }
            else if (size == DefaultBootstrapSize.Sm)
            {
                size = DefaultBootstrapSize.Md;
            }
            else if (size == DefaultBootstrapSize.Md)
            {
                size = DefaultBootstrapSize.Lg;
            }
            else if (size == DefaultBootstrapSize.Lg)
            {
                size = DefaultBootstrapSize.Xl;
            }
            else if (size == DefaultBootstrapSize.Xl)
            {
                size = DefaultBootstrapSize.Xs;
            }

            return(size);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var imageChange        = FindViewById <BootstrapThumbnail>(Resource.Id.bthumb_image_change_example);
            var themeChange        = FindViewById <BootstrapThumbnail>(Resource.Id.bthumb_theme_change_example);
            var borderChange       = FindViewById <BootstrapThumbnail>(Resource.Id.bthumb_border_change_example);
            var roundedChange      = FindViewById <BootstrapThumbnail>(Resource.Id.bthumb_rounded_change_example);
            var sizeChange         = FindViewById <BootstrapThumbnail>(Resource.Id.bthumb_size_change_example);
            var setBitmapExample   = FindViewById <BootstrapThumbnail>(Resource.Id.bthumb_set_image_bitmap_example);
            var setDrawableExample = FindViewById <BootstrapThumbnail>(Resource.Id.bthumb_set_image_drawable_example);
            var setResourceExample = FindViewById <BootstrapThumbnail>(Resource.Id.bthumb_set_image_resource_example);

            var bm = BitmapFactory.DecodeResource(Resources, Resource.Drawable.small_daffodils);

            setBitmapExample.SetImageBitmap(bm);

            setDrawableExample.SetImageDrawable(Com.Beardedhen.Androidbootstrap.Utils.DrawableUtils.ResolveDrawable(Resource.Drawable.ladybird, this));

            setResourceExample.SetImageResource(Resource.Drawable.caterpillar);
            sizeChange.LayoutParameters = (GetLayoutParams(size.ScaleFactor()));

            imageChange.SetOnClickListener(new ViewOnClick(v =>
            {
                switch (resId)
                {
                case Resource.Drawable.ladybird:
                    resId = Resource.Drawable.caterpillar;
                    break;

                case Resource.Drawable.caterpillar:
                    resId = 0;
                    break;

                case 0:
                    resId = Resource.Drawable.ladybird;
                    break;
                }
                imageChange.SetImageResource(resId);
            }));
            themeChange.SetOnClickListener(new ViewOnClick(v =>
            {
                themeChange.ChangeBootstrapBrand();
            }));
            roundedChange.SetOnClickListener(new ViewOnClick(v =>
            {
                roundedChange.Rounded = !roundedChange.Rounded;
            }));
            borderChange.SetOnClickListener(new ViewOnClick(v =>
            {
                borderChange.BorderDisplayed = !borderChange.BorderDisplayed;
            }));
            sizeChange.SetOnClickListener(new ViewOnClick(v =>
            {
                size = size.ChangeBootstrapSize();
                sizeChange.SetBootstrapSize(size);
                sizeChange.LayoutParameters = GetLayoutParams(size.ScaleFactor());
            }));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var defaultExample     = FindViewById <BootstrapProgressBar>(Resource.Id.example_progress_default);
            var animatedExample    = FindViewById <BootstrapProgressBar>(Resource.Id.example_progress_animated);
            var stripedExample     = FindViewById <BootstrapProgressBar>(Resource.Id.example_progress_striped);
            var stripedAnimExample = FindViewById <BootstrapProgressBar>(Resource.Id.example_progress_striped_animated);
            var changeExample      = FindViewById <BootstrapProgressBar>(Resource.Id.example_progress_change);
            var sizeExample        = FindViewById <BootstrapProgressBar>(Resource.Id.example_size_change);


            FindViewById <Button>(Resource.Id.example_progress_default_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                defaultExample.Progress = RandomProgress(defaultExample.Progress, 100);
            }));

            FindViewById <Button>(Resource.Id.example_progress_animated_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                animatedExample.Progress = RandomProgress(animatedExample.Progress, 100);
            }));
            FindViewById <Button>(Resource.Id.example_progress_striped_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                stripedExample.Progress = RandomProgress(stripedExample.Progress, 100);
            }));
            FindViewById <Button>(Resource.Id.example_progress_striped_animated_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                stripedAnimExample.Progress = RandomProgress(stripedAnimExample.Progress, 100);
            }));
            FindViewById <Button>(Resource.Id.example_progress_change_type_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                changeState            = changeState.Next();
                changeExample.Striped  = changeState.Striped;
                changeExample.Animated = changeState.Animated;
            }));
            FindViewById <Button>(Resource.Id.example_progress_change_rounded_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                changeExample.Rounded = !changeExample.Rounded;
            }));
            FindViewById <Button>(Resource.Id.example_progress_change_color_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                changeExample.ChangeBootstrapBrand();
            }));
            FindViewById <Button>(Resource.Id.example_size_change_btn).SetOnClickListener(new Utils.ViewOnClick(v =>
            {
                size = size.ChangeBootstrapSize();
                sizeExample.SetBootstrapSize(size);
            }));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var orientationChange = FindViewById <BootstrapButtonGroup>(Resource.Id.bbutton_group_orientation_change);
            var sizeChange        = FindViewById <BootstrapButtonGroup>(Resource.Id.bbutton_group_size_change);
            var outlineChange     = FindViewById <BootstrapButtonGroup>(Resource.Id.bbutton_group_outline_change);
            var roundedChange     = FindViewById <BootstrapButtonGroup>(Resource.Id.bbutton_group_rounded_change);
            var brandChange       = FindViewById <BootstrapButtonGroup>(Resource.Id.bbutton_group_brand_change);
            var childChange       = FindViewById <BootstrapButtonGroup>(Resource.Id.bbutton_group_child_change);

            var checkedText = FindViewById <TextView>(Resource.Id.bbutton_group_checked_text);

            var radioButton1 = FindViewById <BootstrapButton>(Resource.Id.bbutton_group_checked1);
            var radioButton2 = FindViewById <BootstrapButton>(Resource.Id.bbutton_group_checked2);
            var radioButton3 = FindViewById <BootstrapButton>(Resource.Id.bbutton_group_checked3);



            radioButton1.SetOnCheckedChangedListener(new OnCheckedChangedListener((btn, isChecked) =>
            {
                if (isChecked)
                {
                    checkedText.SetText("radio, button 1 checked", TextView.BufferType.Normal);
                }
            }));
            radioButton2.SetOnCheckedChangedListener(new OnCheckedChangedListener((btn, isChecked) =>
            {
                if (isChecked)
                {
                    checkedText.SetText("radio, button 2 checked", TextView.BufferType.Normal);
                }
            }));
            radioButton3.SetOnCheckedChangedListener(new OnCheckedChangedListener((btn, isChecked) =>
            {
                if (isChecked)
                {
                    checkedText.SetText("radio, button 3 checked", TextView.BufferType.Normal);
                }
            }));


            FindViewById <Button>(Resource.Id.bbutton_group_orientation_change_btn).SetOnClickListener(new ViewOnClick(v =>
            {
                bool isHorizontal             = orientationChange.Orientation == Orientation.Horizontal;
                var newOrientation            = isHorizontal ? Orientation.Vertical : Orientation.Horizontal;
                orientationChange.Orientation = newOrientation;
            }));
            FindViewById <Button>(Resource.Id.bbutton_group_outline_change_btn).SetOnClickListener(new ViewOnClick(v =>
            {
                outlineChange.ShowOutline = !outlineChange.ShowOutline;
            }));
            FindViewById <Button>(Resource.Id.bbutton_group_rounded_change_btn).SetOnClickListener(new ViewOnClick(v =>
            {
                roundedChange.Rounded = !roundedChange.Rounded;
            }));
            FindViewById <Button>(Resource.Id.bbutton_group_child_add_btn).SetOnClickListener(new ViewOnClick(v =>
            {
                int count = childChange.ChildCount;

                BootstrapButton button = new BootstrapButton(this);
                button.SetText((count + 1).ToString(), TextView.BufferType.Normal);

                childChange.AddView(button);
            }));
            FindViewById <Button>(Resource.Id.bbutton_group_child_remove_btn).SetOnClickListener(new ViewOnClick(v =>
            {
                int count = childChange.ChildCount;

                if (count > 0)
                {
                    childChange.RemoveViewAt(count - 1);
                }
            }));
            FindViewById <Button>(Resource.Id.bbutton_group_brand_change_btn).SetOnClickListener(new ViewOnClick(v =>
            {
                brandChange.ChangeBootstrapBrand();
            }));
            FindViewById <Button>(Resource.Id.bbutton_group_size_change_btn).SetOnClickListener(new ViewOnClick(v =>
            {
                size = size.ChangeBootstrapSize();
                sizeChange.SetBootstrapSize(size);
            }));
        }