大家好,我想使用切换按钮,但具有不同的指示器颜色(如绿色或红色),如何更改指示器的颜色。
我使用 Gooogle Colab 来记录我在学习“Google IT Automation with Python”课程时所学到的代码。
我使用目录功能按主题对代码部分进行分组。可以在主窗口中切换这些部分以显示或隐藏其内容。
然而,随着如此多的代码的建立,我想要一种快速关闭所有切换的方法,如图所示。
(或者,如果有人有更好的方法或者可以推荐一个更好的平台来以易于检索的方式构建、测试和组织代码片段,我欢迎您的推荐)。
谢谢!
我有一个页面,其中包含一个简单的复选框表单,其中包含一个提交按钮,供用户将该项目标记为"想要播放".
鉴于简单,我想用单个DIV和切换按钮或开关或其他东西的图形替换它,以便用户可以点击它来标记,但不必打扰愚蠢的单个复选框和提交按钮,相当难看.
我能想到的简短而快速的解决方案是让div成为一个类似的链接
markme.php?id=XYZ&user=123
将该标志弹出到该用户的数据库中,然后重定向回他们正在查看的页面.
那会合理吗?有没有更好的办法?
/我是一个热心的初学者
如果div包含一串文本,我试图让一个按钮切换.就像是:
$(document).ready(function(){
$(function() {
if ('$div#trackingnumber:contains('Hello')');') {
$("dinput#submitam").toggle()});
}
});
Run Code Online (Sandbox Code Playgroud)
有人知道怎么做这个吗?
这里发生了什么,以及如何解决方法?
XAML:
<StackPanel>
<ToggleButton x:Name="MyToggleButton" Content="MyToggleButton" Checked="MyToggleButton_Checked"/>
<TextBlock Text="{Binding IsChecked, ElementName=MyToggleButton}" Margin="0,4"/>
<Button Name="EnableButton" Content="Enable" Click="EnableButton_Click"/>
<Button Name="DisableButton" Content="Disable" Click="DisableButton_Click"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
代码隐藏:
void MyToggleButton_Checked(object sender, RoutedEventArgs e)
{
MyToggleButton.IsEnabled = false;
}
void EnableButton_Click(object sender, RoutedEventArgs e)
{
MyToggleButton.IsEnabled = true;
}
void DisableButton_Click(object sender, RoutedEventArgs e)
{
MyToggleButton.IsEnabled = false;
}
Run Code Online (Sandbox Code Playgroud)
UPD:
目前唯一可行的解决方法是:
void EnableButton_Click(object sender, RoutedEventArgs e)
{
MyToggleButton.IsEnabled = true;
var controlTemplate = MyToggleButton.Template;
var buttonChrome = (Microsoft.Windows.Themes.ButtonChrome)controlTemplate.FindName("Chrome", MyToggleButton);
buttonChrome.RenderPressed = false;
buttonChrome.RenderPressed = …Run Code Online (Sandbox Code Playgroud) 好吧,我很抱歉这个奇怪的标题,但找不到更好的标题.好吧,我正在开发一个WPF应用程序.我正在研究滑块和ToggleButtons.这是一个愚蠢的情况.让我告诉你我的代码:
XAML:
<ToggleButton Name="OneSixBit" Content="16 Bit" />
<ToggleButton Name="ThreeTwoBit" Content="32 Bit" />
<ToggleButton Name="TwentyBit" Content="20 Bit" />
<ToggleButton Name="TwentyFourBit" Content="24 Bit" />
<Label Name="BitDelay" Content="Bit Delay" />
<Slider Minimum="0.0" Maximum="255.0" TickFrequency="1.0" Name="bitdelayslider" />
<TextBox Name="BitDelayValue" IsReadOnly="True" Text="{Binding ElementName=bitdelayslider,Path=Value}" />
Run Code Online (Sandbox Code Playgroud)
我这里有两个问题:
在Togglebuttons中,我想一次将切换状态设置为checked=true一个按钮.即如果Btn1的切换状态是checked=true,我点击任何其他切换按钮,它不应该检查,除非我checked=false在btn1上.
我有一个最大值从0.0到255.0的滑块,它应该以1的频率移动.每当我移动滑块时,我能够在文本框上显示值,但它显示超过1个小数点.即当我从0.0移动时,显示的值是2.3456 ......等.如何确保只能看到单个小数点?
谢谢 :)
如何修复由于后续样式引起的异常?
<Style x:Key="OnOffSwitchToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid Margin="0,0,0,-0.033">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.456*"/>
<ColumnDefinition Width="0.544*"/>
</Grid.ColumnDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="Switch">
<EasingDoubleKeyFrame KeyTime="0" Value="0.083"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path1">
<EasingColorKeyFrame KeyTime="0" Value="White"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(DropShadowEffect.Opacity)" Storyboard.TargetName="path">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" Storyboard.TargetName="path">
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="#FF39B54A"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="path">
<EasingColorKeyFrame KeyTime="0:0:0.2" Value="#FF319D40"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="label"> …Run Code Online (Sandbox Code Playgroud) 如何让这个切换按钮状态保存并在我使用共享首选项的所有活动中使用,我把共享首选项代码,但这一个不起作用,所以有我错过的东西或这个代码是错误的
这是新代码和全班代码,请检查一下,也许会对代码产生影响
public class CollectionPrayersTextActivity extends Activity {
boolean on;
public SharedPreferences tprefs;
final String PREF_NAME="preferences";
public static TextView textview;
private SharedPreferences prefs;
private SeekBar seekbar;
private ToggleButton toggle;
private LinearLayout linear;
@Override
protected void onCreate(Bundle savedInstanceState) {
// Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
// Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Window window = getWindow();
// Unlock the device if locked
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
// Turn screen on if off
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
// Keep screen on
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// Transition between activities
overridePendingTransition(R.anim.incoming, R.anim.outgoing);
// On …Run Code Online (Sandbox Code Playgroud) 所以我有两个切换按钮,我试图结合 - 有点.所以第一个按钮根据IsChecked是真还是假来切换图像,但是这个按钮周围有一个我无法摆脱的边框.
第二个切换按钮没有边框,单击时不闪烁,但也不会根据图像的状态更改图像.
我想要的是两个世界中最好的.更改图像并摆脱边框.我已经尝试了23件事,但没有一件工作.
这是我正在使用的代码:
<ToggleButton x:Name="changeButBorderedBlinky" Margin="0,12,194,0" Width="82" Height="82" Background="Transparent" Padding="-1" Focusable="false" VerticalAlignment="Top" HorizontalAlignment="Right">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Content">
<Setter.Value>
<Border BorderThickness="0" >
<Image Source="images/buttonimages/back2.png" Stretch="Fill" />
</Border>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content">
<Setter.Value>
<Border BorderThickness="0" >
<Image Source="images/buttonimages/back.png" Stretch="fill" />
</Border>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
<ToggleButton x:Name="noChangeNoBorder" Margin="0,12,104,0" VerticalAlignment="Top" HorizontalAlignment="Right" Height="80" Width="80" >
<ToggleButton.Template>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="border" >
<Image x:Name="img" Source="images/buttonimages/back2.png" />
</Border>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
Run Code Online (Sandbox Code Playgroud)
感谢您的帮助.这让我疯了.