Questions tagged [android-switch]

Switch is an android class for a two state toggle switch

From Android Developer Documentation:

A Switch is a two-state toggle switch widget that can select between two options. The user may drag the "thumb" back and forth to choose the selected option, or simply tap to toggle as if it were a checkbox. The text property controls the text displayed in the label for the switch, whereas the off and on text controls the text on the thumb. Similarly, the textAppearance and the related setTypeface() methods control the typeface and style of label text, whereas the switchTextAppearance and the related seSwitchTypeface() methods control that of the thumb.

The Android Developer Guide regarding toggle buttons also states, that

The ToggleButton and Switch controls are subclasses of CompoundButton and function in the same manner, so you can implement their behavior the same way.

201 questions
1
vote
3 answers

How can I add a link to the text of a Switch widget?

I am trying to make an "Accept terms and conditions" switch. I was able to add the link into the switch but the problem is that the link is also on the switch button so each time I press the button to accept the terms and conditions it carry me to…
Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
1
vote
3 answers

how to align to right and middle in height in layout

I have a Switch, witch is aligned to the left of a layout, I want to align a TextView to the right of it AND to the middle of the height of it. I have done two example pictures to explain it more clearly. This is what i have (where A is the…
Chief Madog
  • 1,738
  • 4
  • 28
  • 55
1
vote
1 answer

how to set recyclerview of switches to perform different function on each switches

I want to list the switch names from the database, and for that I have already implemented the application for Recyclerview list. Now, the problem is, my Recyclerview item contains the switch element, and I want to perform two functions on turning…
1
vote
1 answer

Android set switch status inside onCheckChangedListener

I want toggle a Switch to false if the user toggles it to true. In order to avoid firing onCheckChanged again, I remove the listener, then add it back after the switch. mCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() { …
jwBurnside
  • 849
  • 4
  • 31
  • 66
1
vote
1 answer

android switch thumb text cutoff

I wanted to implement an Switch widget in my app and the function works perfectly. The issue I have with the switch is the off text ("OFF") on the thumb. "OFF" is bigger than the size of the thumb. I want to increase the size of the thumb (or…
1
vote
1 answer

Android, Hide stock toggle when using custom background?

I've got a custom drawable for my toggle switch // toggle_selector.xlm
Birrel
  • 4,754
  • 6
  • 38
  • 74
1
vote
2 answers

ViewHolder holding an android.widget.Switch, Switch not responding to listener

Ok, I have a holder, holding a bunch of elements that won't change except for the switch (obviously). I reduced the code, for it to be simpler to read, I thought this would allow me to see in the logs the state being changed of the switches (which…
1
vote
1 answer

State of a switch

I want to get the state of a switch in the onClick method of a button. Actually I want to save the state of a switch using the save button using Shared Preferences. For this I require the state of the Switch in the onClick method for the save…
pirate
  • 11
  • 2
1
vote
1 answer

How to Create Sliding Buttons in Android?

I want to create sliding buttons in Android, When we slide up the light indicator will glow, as we need change image while sliding it. I have tried with toggle button and switch but its not having sliding effect? Any suggestion on this.
1
vote
1 answer

android Switch not toggling programmatically

I am trying to toggle a switch back to the off state programmatically, however I am running into a problem. I have tried using both myswitch.setischecked(false) and myswitch.toggle and they both leave the switch on the current state but change the…
dave
  • 1,410
  • 1
  • 16
  • 42
1
vote
1 answer

Assgin label "pro" on switch

I'm new to android programming. I want to customize the switch like below figure.                   And also I want to control the spaces between text and switch. What changes I have to add pro label on my switch?
gangadhars
  • 2,584
  • 7
  • 41
  • 68
1
vote
2 answers

Shared Preferences and Preference Fragment

Here are my questions: How can I get the value of a switch preference? Are things inside a preference fragment already a shared preference? If so, how can I access shared preferences from a preference fragment?
1
vote
1 answer

obfuscating nineoldandroids and android-switch-backport with proguard

I 'am using proguard with eclipse to obfuscate a android proyect which has nineoldandroid library and switch backport, I get the following warnings: Tappsi_pasajero] Warning: class…
juan Isaza
  • 3,646
  • 3
  • 31
  • 37
1
vote
0 answers

Android Switch xml textOn string resource

Is there a way to specify a resource id in XML for a Switch? When I do the following I get random integers which I'm assuming are the id itself and not the resolved String?
StackJP
  • 1,450
  • 2
  • 16
  • 32
0
votes
2 answers

Xamarin.Android Switch -Set colors of thumb and track drawables

I have a switch with custom track and thumb.
Gith
  • 3
  • 3