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
0
votes
0 answers

Why doesn't the Switch added to tool bar pick up colors from styles.xml?

I am trying to add a switch to the tool bar. It is showing up, but the color of the switch is not getting picked up from styles.xml. What am I doing wrong? Home.java public class Home extends AppCompatActivity { @Override protected void…
sofs1
  • 3,834
  • 11
  • 51
  • 89
0
votes
4 answers

how to add color to the circle in the switch in android?

I want to create a switch which looks like this i have done that in this way
yacky
  • 313
  • 1
  • 6
  • 19
0
votes
1 answer

How to fix custom switch appearance on Android 4

I have a custom switch element which looks great on Android 5 and 6. But there is a problem with Android 4. The question is how to keep shape of the toggle circular? Android 5,6. Picture 1 Android 4. Picture 2 Here is my code:
Oleh Liskovych
  • 991
  • 3
  • 13
  • 31
0
votes
0 answers

how to set SwitchPreference toggle because marshmallow only show the On OFF text but not display toggle

my app SwitchPreference only show the ON or OFF text But not display toggle how to show toggle in my application any one help me. i tried but the toggle is not display only show text Not display Toggle
0
votes
1 answer

Intent to fragment not working

I'm having trouble sending intent to fragment. I'm trying to send intent from one class to another, then setArgument for the fragment. In the fragment I then want a switch statement to set the data to the recycler view based on the value of the…
0
votes
1 answer

android:Thumb disables Switch

I am trying to change the color of the Switch Thumb, I have created following drawable file.
dev90
  • 7,187
  • 15
  • 80
  • 153
0
votes
2 answers

How to update Viewholder class after volley response

I am beginner in android development. I am creating an Application in which there is recycleView with CardView. inside cardview I am using one TextView and One Switch button. when i change the button value to server it is updated there. I want to…
0
votes
0 answers

Change text colour of SwitchCompat

How can I change text colour of SwitchCompat?I am showing On and Off text in SwitchCompat and i want to change text colour to white.
0
votes
0 answers

Android: how to achieve Material Design specs look with a standard Switch?

I want to achieve a look like this (from the material design specs) for my switch when it's in the off state: notice that the thumb is white and has a black outline with a slight shadow. I haven't been able to replicate this at all - much less to…
Jon
  • 7,941
  • 9
  • 53
  • 105
0
votes
0 answers

Not sure how to implement a switch within a listView

so The issue I am facing is that I have a listView that contains a switch and some additional data that is in JSON. I need to be able to send the position of the switch (on or off) and one part of the json, the deviceID and then send them to the…
GingerFish
  • 457
  • 3
  • 11
  • 26
0
votes
2 answers

Controlling Multiple Switch button in Android

I'm Building a simple profile manager android application Using Switch Button in Android. There are 3 switches named General,Silent and Vibrate. Problem is all 3 switches are working together I want the General Switch to be disabled when the…
0
votes
3 answers

Android studio Switch setOnCheckedChangeListener parameter

=========================================================================== Thank you for your answers! I changed my codes and I added some TextViews to check if my coding works(if variables change correctly), but I can't see any value under "LED…
0
votes
1 answer

Android Studio adding "Switch" to child group of ExpandableListView

I made expandablelistview with textView and switch in the child group. I want to use the status of switch(On or OFF) to control the device connected to the ESP8266 WiFi module. How can I store the switch data to use it somewhere else? Adapter java…
0
votes
0 answers

listen Switch in ActionBar

I have a class and try to do a listener for a switch in Actionbar. I tried it like here:Link In my content_main.xml I put it like this:
0
votes
0 answers

How onSharedPreferenceChanged works?

I am using shared preference variable in one (first) file and onSharedPreferenceChanged in an other (second) file. Based on the value of shared preference variable value, i want to perform some task. Whenever sharedpreference variable value is…