本文整理汇总了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;
}
示例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();
}
};
}
示例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);
}
示例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;
}