Questions tagged [android-togglebutton]

A toggle button allows the user to change a setting between two states.

A toggle button allows the user to change a setting between two states. It displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF".

For more information, see the Toggle Buttons guide.

199 questions
0
votes
2 answers

android.widget.Switch cannot be cast to android.widget.ToggleButton

I got these simple lines of code: MainActivity: public class MainActivity extends FragmentActivity implements ActionBar.TabListener { (...) public void VehicleDeleteModus(View v){ boolean on = ((ToggleButton) v).isChecked(); (...) …
Fabian
  • 748
  • 2
  • 11
  • 20
-1
votes
1 answer

How to customize toggle button in android?

I've been trying to customize a toggle button to look like this, but it seems like i'm not getting anywhere. Can anyone give me an idea or any kind of tutorial on designing?
-1
votes
2 answers

How to handle ToggleButton state in OnPause and OnResume state

I am facing problem with toggle button state on onResume() and onPause() state. Activity - A (first user toggle ON the button) then go back to Activity - B, then it will comeback to Activity - A then I want toggle Button is ON not OFF, how to handle…
-1
votes
4 answers

multiple toggle button enable or disable in a single method

I have a 3 toggleButtons and if 1 is enabled other 2 will be disabled. I am able to achieve this through if statement. But I need to write different if for all the toggleButtons. case toggleButton1: if(toggleButton[0].isChecked()) …
user2269164
  • 1,095
  • 2
  • 15
  • 31
-1
votes
2 answers

Set CheckBox enabled if togglebutton is checked

I created a Togglebutton for my push notification service (if the button is checked, notifications will be reveived). I also want, that when I check the button, a checkbox is checkbox. If the button isn't check, the checkbox should disabled. I used…
N.Preusche
  • 37
  • 1
  • 2
  • 7
-1
votes
4 answers

How to enable and disable toast with toggle button in Android?

I have toggle button which work good for some function. But when I use for toast, toggle button is null pointer. This is my code: if (tgbutton.isChecked()) { Toast.makeText(getApplicationContext(), "MY TEXT HERE", Toast.LENGTH_LONG).show(); …
Bonnie7
  • 19
  • 1
  • 10
-1
votes
1 answer

Drawable of a custom toggle button not centered

I'm trying to simulate a checkbox with a togglebutton, because I need to customize the entire widget, so I'm trying the next code, but the image is positioning on the left, and I need to put it centered.
Víctor Martín
  • 3,352
  • 7
  • 48
  • 94
-1
votes
5 answers

how to get Toggle or switch selected item value to string?

I am using this library to implment toogle button https://github.com/GwonHyeok/StickySwitch How can I get Switch item as male or female value to string ? enter image description here MainActivity: public class MainActivity extends AppCompatActivity…
User_FIt
  • 1
  • 5
-1
votes
1 answer

design custom toggle button in android

Can any body please tell me how to design the custom toggle button.
eLemEnt
  • 1,741
  • 14
  • 21
-1
votes
1 answer

how to make toggle with 3 selection in android?

My question is very simple. Is there any way to make a toggle button which will provide user to select 3 options like ON,OFF,NEUTRAL? I search a lot, but other options are there like use spinner but I wanna customize toggle button. Any idea how to…
AMAN SINGH
  • 3,491
  • 6
  • 28
  • 44
-1
votes
5 answers

Handle ToggleButton in onResume()

I have written a program in which I am using Timer and controlling that timer using Toggle states. Toggle's default state is OFF, once I make changes in toggle state from OFF to ON Timer starts, and when I again change to OFF it stops the Timer as…
-1
votes
1 answer

how to get same Background drawable with different button android

Hello I had a problem with equate id background from same drawable xml. I have view with 2 toggle button like this
jboxxpradhana
  • 468
  • 2
  • 6
  • 22
-1
votes
2 answers

Change EditText value from text to password and vice versa on ToggleButton checked

I am studying programming in Android and I'm hitting an issue. I have this toggle button and when I input a text and the button is on, the text is starred (passworded, call it whatever you want) and when the button is off, the text is a text.…
MrSilent
  • 564
  • 10
  • 28
-2
votes
3 answers

ToggleButton image does not maintain aspect ratio

The two toggle buttons don't maintain aspect ratio. How can I make it a square? It shouldn't fill the width but just wrap it's content.
Jim Clermonts
  • 1,694
  • 8
  • 39
  • 94
-2
votes
3 answers

Save Switch Button State via Shared Preferences When App is Closed

In my Activity I have an Switch Button. I wanted to keep the State of the Switch Button when the App closes from the background. The State of the Switch remains when the App is there in the Background but it goes back to the default (OFF) state when…
1 2 3
13
14