当前位置: 首页>>代码示例>>C#>>正文


C# ToggleButton.SetBackgroundResource方法代码示例

本文整理汇总了C#中ToggleButton.SetBackgroundResource方法的典型用法代码示例。如果您正苦于以下问题:C# ToggleButton.SetBackgroundResource方法的具体用法?C# ToggleButton.SetBackgroundResource怎么用?C# ToggleButton.SetBackgroundResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ToggleButton的用法示例。


在下文中一共展示了ToggleButton.SetBackgroundResource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreateView

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.HomeScreen, container, false);
            infoButton = view.FindViewById<Button>(Resource.Id.infoButton);
            player = MediaPlayer.Create(view.Context, Resource.Raw.avril_14th);
            toggleMusic = view.FindViewById<ToggleButton>(Resource.Id.toggleMusic);
            cover = view.FindViewById<RelativeLayout>(Resource.Id.titleScreen);

            Xamarin.Insights.Initialize(XamarinInsights.ApiKey, view.Context);
            CurrentPlatform.Init();

            player.Start();
            player.Looping = true;

            cover.Click += delegate
            {
                facebookLogin.Invoke(this, new LoginEventArgs());
            };

            toggleMusic.Click += (o, s) => {

                if (toggleMusic.Checked)
                {
                    player.Start();
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);
                }
                else {
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
                    player.Pause();
                }
            };

            return view;
        }
开发者ID:knervous,项目名称:MemBox1,代码行数:34,代码来源:HomeScreenFragment.cs

示例2: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ActionBar.Hide();
            SetContentView(Resource.Layout.Main);
            cover = FindViewById<RelativeLayout>(Resource.Id.titleScreen);
            player = MediaPlayer.Create(this, Resource.Raw.avril_14th);
            toggleMusic = FindViewById<ToggleButton>(Resource.Id.toggleMusic);
            player.Start();
            player.Looping = true;

            cover.Click += delegate
            {
                StartActivity(typeof(Login));
            };


            toggleMusic.Click += (o, s) =>

            {
                if (toggleMusic.Checked)
                {
                    player.Start();
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);

                }
                else
                {
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
                    player.Pause();
                }
            };


        }
开发者ID:knervous,项目名称:MemoryBox,代码行数:35,代码来源:MainActivity.cs

示例3: OnCreateOptionsMenu

        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.alarm_screen, menu);

            _deleteAlarmMenuItem = menu.FindItem(Resource.Id.delete);
            _disableAlarmMenuItem = menu.FindItem(Resource.Id.switch_button);

            _enableAlarmToggleButton = MenuItemCompat.GetActionView(_disableAlarmMenuItem) as ToggleButton;
            _enableAlarmToggleButton.SetBackgroundResource(Resource.Drawable.toggle_button);
            _enableAlarmToggleButton.Checked = _selectedAlarm.Enabled;
            _enableAlarmToggleButton.CheckedChange += AlarmEnabledChange;

            CorrectOptionsMenuVisibility();

            return base.OnCreateOptionsMenu(menu);
        }
开发者ID:foxanna,项目名称:SimpleLocationAlarm,代码行数:16,代码来源:AlarmScreen.cs

示例4: CreateDeviceSelectionItem

        private ToggleButton CreateDeviceSelectionItem(Device moj)
        {
            ToggleButton button = new ToggleButton (this);
            if (devicesToShow.Contains (moj))
                button.Checked = true;
            else
                button.Checked = false;

            button.SetBackgroundResource (Resource.Drawable.android_blue_button);
            button.Text = string.Format ("{0}", moj.Name);
            button.Tag = moj.Id;
            button.Click += OnDeviceSelected;
            return button;
        }
开发者ID:rockyhe,项目名称:MojioTowingAlert,代码行数:14,代码来源:NotificationsActivity.cs


注:本文中的ToggleButton.SetBackgroundResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。