标签: togglebutton

如何更改切换按钮中的指示器颜色(Android)

大家好,我想使用切换按钮,但具有不同的指示器颜色(如绿色或红色),如何更改指示器的颜色。

查看 imgur 上的默认指示器

android indicator togglebutton

4
推荐指数
2
解决办法
2万
查看次数

在 Google Colab 中,是否可以使用快捷方式展开/折叠所有部分切换?

我使用 Gooogle Colab 来记录我在学习“Google IT Automation with Python”课程时所学到的代码。

我使用目录功能按主题对代码部分进行分组。可以在主窗口中切换这些部分以显示或隐藏其内容。

然而,随着如此多的代码的建立,我想要一种快速关闭所有切换的方法,如图所示。

(或者,如果有人有更好的方法或者可以推荐一个更好的平台来以易于检索的方式构建、测试和组织代码片段,我欢迎您的推荐)。

谢谢!

在此输入图像描述

keyboard-shortcuts togglebutton google-colaboratory

4
推荐指数
1
解决办法
5360
查看次数

编写一个大的单击切换按钮来替换单个复选框并提交按钮表单的最佳方法是什么?

我有一个页面,其中包含一个简单的复选框表单,其中包含一个提交按钮,供用户将该项目标记为"想要播放".

鉴于简单,我想用单个DIV和切换按钮或开关或其他东西的图​​形替换它,以便用户可以点击它来标记,但不必打扰愚蠢的单个复选框和提交按钮,相当难看.

我能想到的简短而快速的解决方案是让div成为一个类似的链接

markme.php?id=XYZ&user=123

将该标志弹出到该用户的数据库中,然后重定向回他们正在查看的页面.

那会合理吗?有没有更好的办法?

/我是一个热心的初学者

php mysql forms togglebutton

3
推荐指数
1
解决办法
7138
查看次数

jQuery如果div包含文本,切换按钮

如果div包含一串文本,我试图让一个按钮切换.就像是:

$(document).ready(function(){
$(function() {
if ('$div#trackingnumber:contains('Hello')');') {
    $("dinput#submitam").toggle()});
}
});
Run Code Online (Sandbox Code Playgroud)

有人知道怎么做这个吗?

javascript jquery toggle togglebutton

3
推荐指数
1
解决办法
2421
查看次数

WPF ToggleButton不正确的渲染行为

这里发生了什么,以及如何解决方法?

  1. 按MyToggleButton.现在它看起来像是立即按下(选中).
  2. 同时MyToggleButton_Checked处理程序禁用MyToggleButton.
  3. 现在按下非切换按钮'启用'.我们看到了什么?MyToggleButton看起来像是启用了.好.但是等等,现在它看起来像是非紧迫的!为什么?!

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 togglebutton

3
推荐指数
1
解决办法
1247
查看次数

未能限制滑块值的小数点+在ToggleButtons上设置IsChecked一次一个

好吧,我很抱歉这个奇怪的标题,但找不到更好的标题.好吧,我正在开发一个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)

我这里有两个问题:

  1. 在Togglebuttons中,我想一次将切换状态设置为checked=true一个按钮.即如果Btn1的切换状态是checked=true,我点击任何其他切换按钮,它不应该检查,除非我checked=false在btn1上.

  2. 我有一个最大值从0.0到255.0的滑块,它应该以1的频率移动.每当我移动滑块时,我能够在文本框上显示值,但它显示超过1个小数点.即当我从0.0移动时,显示的值是2.3456 ......等.如何确保只能看到单个小数点?

谢谢 :)

.net c# wpf slider togglebutton

3
推荐指数
1
解决办法
1437
查看次数

'[Unknown]'属性不指向路径'(0)中的DependencyObject.(1)[3].(2)'

如何修复由于后续样式引起的异常?

        <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)

c# wpf xaml styles togglebutton

3
推荐指数
2
解决办法
4625
查看次数

如何使用共享首选项保存togglebutton状态

如何让这个切换按钮状态保存并在我使用共享首选项的所有活动中使用,我把共享首选项代码,但这一个不起作用,所以有我错过的东西或这个代码是错误的

这是新代码和全班代码,请检查一下,也许会对代码产生影响

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)

android togglebutton sharedpreferences

3
推荐指数
1
解决办法
7077
查看次数

WPF ToggleButton XAML样式

所以我有两个切换按钮,我试图结合 - 有点.所以第一个按钮根据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)

感谢您的帮助.这让我疯了.

wpf xaml togglebutton wpf-style

3
推荐指数
1
解决办法
3万
查看次数

Android:Tab类似于切换按钮选择器而不是微调器

我有一个Android应用程序,在一个活动中我需要一个像选择器的选项卡,用户可以选择一个选项.3个选项是蓝色,绿色,红色.用户需要选择其中任何一个.我可以使用微调器.但是我喜欢使用圆形边框标签,可以切换,所选项目将突出显示,其他项目将显示为灰色,如下所示. 切换选项卡选择器 我只是希望用户能够只切换其中一个按钮.用户可以通过点击或切换来选择一个选项,视图应该看起来像一个带有圆边的条.如何在android中实现上面的视图?请帮我.

tabs android toggle togglebutton

3
推荐指数
1
解决办法
2855
查看次数