我已经了解了如何<audio>通过放置此代码来静音声音对象:
<a href="#" onclick="document.getElementById('ambiance').muted = true; return false">
mute sound
</a>
Run Code Online (Sandbox Code Playgroud)
现在我正在搜索如何使用相同的按钮来选择切换声音来静音/取消静音?
谁能给我指示?
我有一个togglebutton,它没有响应我的setChecked(...)方法.这是代码:
mBool = mPrefs.getBoolean("buttondefault", true);
Boolean b = mBool; //Only creating this for Logging, mBool IS PRIMITIVE
Log.e("Update pref", b.toString());
mToggle = (ToggleButton)findViewById(R.id.ac_toggle);
mToggle.setOnClickListener(this);
mToggle.setChecked(mBool);
Run Code Online (Sandbox Code Playgroud)
日志报告mBool为true,当我mToggle.setChecked(mBool)按下时按钮保持在关闭位置.
这是按钮的xml:
<ToggleButton android:id="@+id/ac_toggle"
android:textOn="Yes"
android:textOff="No"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3sp"
android:layout_weight="5"/>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我无法更改迷你版本的翻转切换开关的宽度,并且文本未全部显示.
如果它不是迷你,我可以使用添加到CSS的技术来改变宽度:
.containing-element .ui-slider-switch { width: 7em }
Run Code Online (Sandbox Code Playgroud)
然后将交换机包含在div中.
如果我设置data-mini ="true"则完全相同,并且切换变为迷你,但我无法改变宽度.
如果翻盖拨动开关是迷你型,我该如何改变宽度?
谢谢
我有一个带有图像的切换按钮,但是当我更改按钮的文本时,文本位于图像后面。我在setText()函数中添加了额外的空格,但这在不同的屏幕尺寸上不能很好地缩放。那我能做什么?
切换按钮的 xml auton_select.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true"
android:drawable="@drawable/auto_select" /> <!-- pressed -->
<item android:state_checked="false"
android:drawable="@drawable/auto_unselect" /> <!-- unchecked -->
<item android:drawable="@drawable/auto_unselect" /> <!-- default -->
</selector>
Run Code Online (Sandbox Code Playgroud)
在布局中使用切换按钮 xml
<ToggleButton
android:id="@+id/auto_ring_button"
android:textOn=" test"
android:textOff=" "
android:disabledAlpha=".9"
android:button="@drawable/auton_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="showPopupR"
/>
Run Code Online (Sandbox Code Playgroud) 我在android中制作了一个自定义切换按钮,选中状态和未选中状态在两个图像上都可以正常工作,现在我想为切换按钮的禁用状态设置禁用图像。我怎么做?谢谢!
这是我的代码
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="false" android:drawable="@drawable/record_off" />
<item android:state_checked="true" android:drawable="@drawable/record_on" />
</selector>
Run Code Online (Sandbox Code Playgroud) 我需要在这个问题中得到解决,不幸的是它是针对 Silverlight 的,我无法使“交互性”库工作。
我有一个ToggleButton,我想在Content未选中时选中“再见”时将属性更改为“你好”。在这种情况下,我不能手动更改它,因为可以从多个来源更改状态。
我认为此任务可能需要转换器,并且我已经看到转换器到 Visibility 而不是字符串。
编辑:我想过将这两个词放在一个堆栈面板中,并将可见性 Visible/Collapsed 绑定到状态:
<ToggleButton.Content>
<StackPanel>
<TextBlock Text="Hello" Visibility="{Binding ...}"/>
<TextBlock Text="GoodBye"/>
</StackPanel>
</ToggleButton.Content>
Run Code Online (Sandbox Code Playgroud) 我正在为我的Android应用程序实现导航抽屉.我通过从侧面拖动来使抽屉工作,但操作栏上的主页/切换按钮不会更改为我想要的图标并且不响应点击,您在其中定义的onDrawerClosed和onDrawerOpened方法被调用.我的代码如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/loadingFragment"
android:name="com.whostr.clients.android.LoadingFragment" />
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/eventFragment"
android:name="com.whostr.clients.android.EventDisplayFragment"/>
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/emptyFragment"
android:name="com.whostr.clients.android.EmptyView"/>
<!-- Listview to display slider menu -->
<ListView android:id="@+id/left_drawer"
android:layout_width = "240dp"
android:layout_height = "match_parent"
android:layout_gravity = "start"
android:choiceMode = "singleChoice"
android:dividerHeight = "1dp"
android:divider = "@android:color/transparent"
android:background="#111"
/>
Run Code Online (Sandbox Code Playgroud)
在活动中我有以下代码:
@Override
public void onCreate(Bundle savedDataInstace)
{
super.onCreate(savedDataInstace);
setContentView(R.layout.eventdisplay);
fm = getSupportFragmentManager();
//get fragments by id
fragments[EVENT_VIEW]= fm.findFragmentById(R.id.eventFragment);
fragments[LOADING] = fm.findFragmentById(R.id.loadingFragment);
fragments[EMPTY_VIEW] = fm.findFragmentById(R.id.emptyFragment);
menuList = …Run Code Online (Sandbox Code Playgroud) 我很简单ToggleButton,当IsChecked我只想更改文本时。我想要所有其他属性,border并且background将是,Transparent但似乎我仍然拥有这个background style:
<ToggleButton x:Name="changeButBorderedBlinky" Content="EDIT" Width="40" Height="40" Background="Transparent">
<ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Content" Value="Done"/>
<Setter Property="FontWeight" Value="Bold"/>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
Run Code Online (Sandbox Code Playgroud) 我只能在项目中使用react native,我需要用AnimatedView制作一个Toggle组件。我尝试使用 React Native Switcher,但它不会同时响应移动和网络。
export const ToggleButton = () => {
const [isEnabled, setIsEnabled] = useState(false);
const [text, setText] = useState('');
const toggleSwitch = () => {
if (isEnabled) {
setText('OFF');
} else {
setText('ON');
}
setIsEnabled(previousState => !previousState);
};
return (
<View style={styles.container}>
<View>
{isEnabled ? <Text style={styles.textOn}>On</Text> : <Text style={styles.textOff}>Off</Text>}
<Switch
trackColor={{ false: Colors.BlueLight, true: Colors.PurpleLight }}
thumbColor={isEnabled ? Colors.BlueLight : Colors.BlueLight}
ios_backgroundColor="#3E3E3E"
onValueChange={toggleSwitch}
value={isEnabled}
/>
</View>
</View>
);
};
Run Code Online (Sandbox Code Playgroud)
有人给我建议如何做?
有没有办法重用WPF中节点旁边出现的简单展开[+]和折叠[-]按钮TreeView?我想在我的应用程序的其他地方有一个类似的图形来扩展和折叠一些控件.
togglebutton ×10
android ×4
wpf ×3
audio ×1
button ×1
c# ×1
html5 ×1
image ×1
javascript ×1
jquery ×1
mute ×1
react-native ×1
reactjs ×1
reusability ×1
toggle ×1
treeview ×1