togglebutton

attach onClickListener to ToggleButton

房东的猫 提交于 2019-12-23 06:45:03
问题 I have a ToggleButton and I need to set up simple click actions. How do I implement a simple click listener for a ToggleButton? If you need details please ask. 回答1: ToggleButton extends View, so you can simply use View.setOnClickListener(), like this: // get your ToggleButton ToggleButton b = (ToggleButton) findViewById(R.id.myButton); // attach an OnClickListener b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // your click actions go here } }); 回答2: this

My code toggles airplane mode continuously

随声附和 提交于 2019-12-23 05:27:45
问题 I have a screen (Activity) that does the following: it has a toggle button that toggles the airplane mode; it does it by using a service that spawn off a new Thread. It also has a button that does exactly the same thing in exactly the same way. There is really nothing fancy as the code snippets below show. While everything works as expected for the toggle button (airplane mode changes to "on" if currently the phone is not in airplane mode; changes to "off" if currently in airplane mode), when

AirPlane ToggleButton?

别说谁变了你拦得住时间么 提交于 2019-12-23 05:13:21
问题 I am trying to use a ToggleButton to switch AirPlane mode on and off. I am not sure how to go about this. My permissions are: <uses-permission android:name="android.permission.WRITE_SETTINGS"/> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/> My .XML file looks like this: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout

Show-hide toggle button for Layout in Android

末鹿安然 提交于 2019-12-23 04:52:23
问题 I was wondering why a button I made to show/hide my layouts only works once, i.e, initially my layouts are GONE, then when I click a button they're VISIBLE, but later when I click the same button, their View is not being set back to GONE. /** * Method to show/hide buttons, on button click. * @param v */ public void hideOrDisplayOptionIconsButton(View v) { // Hide layouts if VISIBLE if(mMapViewsButtonsLinearLayout.getVisibility() == View.VISIBLE && mLocationButtonsLinearLayout.getVisibility()

WPF EditingCommands is not working when RichTextBox is just load/empty?

荒凉一梦 提交于 2019-12-22 11:08:13
问题 Here is a very simple code example: <DockPanel> <ToolBar DockPanel.Dock="Top" IsTabStop="False"> <ToggleButton MinWidth="40" Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=XAMLRichBox}" TextBlock.FontWeight="Bold" IsTabStop="False">B</ToggleButton> </ToolBar> <RichTextBox x:Name="XAMLRichBox" SpellCheck.IsEnabled="True" MinHeight="100"/> </DockPanel> when I run it, after typing something into the RichTextBox , I can use the ToggleButton to get the BOLD effect, and

How to change the text color of an Android ToogleButton on state change?

只谈情不闲聊 提交于 2019-12-21 09:19:22
问题 my toggle-Button has different colored backgrounds for each state(red and white). Now I need to change the color of the togglebutton-text(red/white) when activated. With xml I just cannot get it working, perhaps anybody has an idea what I'm doing wrong? My button in the Layout xml: <ToggleButton android:paddingRight="20dip" android:id="@+id/pseudo_tab_right" android:layout_weight=".50" android:layout_width="wrap_content" android:textStyle="bold" android:paddingLeft="10dip" android:textSize=

Popup and Togglebutton interaction in wpf

老子叫甜甜 提交于 2019-12-21 09:07:35
问题 I have a control that contains a Togglebutton and a Popup. When the ToggleButton is clicked on, the popup appears. When the ToggleButton is unchecked, the popup should close. Additionally, clicking away from the popup should cause it to close, and cause the Togglebutton to uncheck. I've set this up by setting the StaysOpen property of the Popup to false, and setting the IsChecked property of the toggle button to be two-way bound to the IsOpen property of the Popup. All is well, apart from one

Removing padding from toggle button in Android

孤者浪人 提交于 2019-12-20 19:49:20
问题 I am creating a simple toggle button in android and setting background as a drawable. <ToggleButton android:layout_width="wrap_content" android:drawablePadding="0dp" android:layout_height="wrap_content" android:text="" android:textSize="12sp" android:padding="0dp" android:id="@+id/tag_text" android:background="@drawable/toggle_selector"/> toggle_selector.xml looks like this: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item

Android ToggleButton always check

て烟熏妆下的殇ゞ 提交于 2019-12-20 07:08:53
问题 I want to store in SharedPreferences if the toggle button is Checked or uncheck. toggle.setOnCheckedChangeListener(new OnCheckedChangeListener(){ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) if(isChecked){ SharedPreferences.Editor editor = getSharedPreferences("SharedPrefName", MODE_PRIVATE).edit(); editor.putBoolean("check", true); editor.commit(); } else { SharedPreferences.Editor editor = getSharedPreferences("SharedPrefName", MODE_PRIVATE).edit(); editor

ToggleButtons and listeners in JavaFX

主宰稳场 提交于 2019-12-20 04:24:16
问题 I have this code @FXML private ToggleButton tb1; @FXML private ToggleButton tb2; @FXML ToggleGroup group = new ToggleGroup(); String cpuLoad1 ="D:/myWorkspace/TestAttacks/input_folder/app_debug.apk"; String cpuLoad2 = "D:/myWorkspace/TestAttacks/input_folder/cpuLoad1.apk"; @FXML private void onToggleClick(){ tb1.setUserData(cpuLoad1); tb1.setToggleGroup(group); tb2.setUserData(cpuLoad2); tb2.setToggleGroup(group); ChangeListener<Toggle> cLt = new ChangeListener<Toggle>(){ public void changed