Questions tagged [switchpreference]
51 questions
1
vote
0 answers
SwitchPreference with Material Design in Android Lollipop?
I've upgraded the code to Android Lollipop but the SwitchPreference still looks the same with the on/off design.
Is it possible to change it to the new Material Design look of a normal Switch ?

Mythul
- 1,807
- 7
- 34
- 53
0
votes
1 answer
SwitchPreferenceCompat wrong "off" color on real device
I'm using SwitchPreferenceCompat from androidx.preference:preference:1.2.0. In Android Studio preview everything looks good:
But in real device it look this:
Here my preferences.xml:

Mikhail
- 2,612
- 3
- 22
- 37
0
votes
1 answer
Programatic SwitchPreference Always Unchecked
I added 3 switch preference in a PreferenceCategory programmatically.

Eric
- 303
- 1
- 8
- 19
0
votes
1 answer
Android: ClassCastException on PreferencesActivity onCreate when app is updated (NOT in first run)
I'm about to launch an update of my app, but facing a problem.
One of the preferences class has been changed from CheckBox to Switch and now users who previously installed the app are getting a crash when trying to access PreferenceActivity.
This is…

Diego Perez
- 2,188
- 2
- 30
- 58
0
votes
1 answer
SettingActivity by using switchpreferenceCompat
I have a preference screen having multiple SwitchpreferenceCompat. I need to give a user choice of theme change,vibration,etc in settingActivity. Can any one help me in how to set vibrate or theme change by clicking switch in settingactivity. I used…

Learner
- 41
- 6
0
votes
1 answer
Icon Change Not Working for SwitchPreference
I'm trying to change the icon for my SwitchPreference depending on its state. If the SwitchPreference is on, I want the icon set to be @drawable/ic_notifications_active, but if it's off I want the icon set to be @drawable/ic_notifications_off.
This…

Bert Hanz
- 417
- 1
- 7
- 16
0
votes
1 answer
How to give contentDescription to SwitchPreference for Accessibilty/Talkback?
I have a Preference screen having multiple SwitchPreferences. I need to give custom contentDescription to each switch for accessibility.
There is no property as contentDescription for SwitchPreference. Can Anyone help me in how to give custom…

Rajdeep Shekhawat
- 3
- 1
- 1
0
votes
1 answer
Android Preference how to select one of multiple items next to each other
Preference Example of multiple selections next to each other
I am trying to add a preference into my PreferenceScreen that allows the user to select one condition from multiple in a single row next to each other (like the image above).
Is there a…

user3498845
- 3
- 5
0
votes
1 answer
Enable/disable two more SwitchPreference when one switch Preference is enabled
When one preference is selected, other two preferences should be available for clicks, otherwise the should be shady/dim so that the user knows they are not clickable. Like how we set alpha for text.
Attached the code below. Please Let me know if…

Harish Dadi
- 55
- 8
0
votes
0 answers
ScrollView and SwitchPreferences at the bottom causes erratic behavior. Why does the list scroll up whenever I toggle a SwitchePreference?
Has anyone experienced this? When I press on a SwitchPreference, the ScrollView scrolls up. This never happens with any other preferences which include MultiSelectListPreference, Preference, and ListPreference.
Even with blank behavior (a listener…

poetryrocksalot
- 697
- 2
- 10
- 19
0
votes
1 answer
Android - How to dynamically change the thumb/track color of a SwitchPreference's switch
So far, I can only change the summary/title text color of a preference with setSpan() on the text, but I couldn't find anything that can change the Switch's color in a SwitchPreference, I considered several plans including set a custom layout, or…

Jack
- 5,354
- 2
- 29
- 54
0
votes
1 answer
SwitchPreference.isEnabled() not detecting if enabled/disabled properly
I'm trying to use SwitchPreference and trying to detect it's state using isEnabled() method.
Here's the code (in SettingsActivity.java):
@Override
protected void onCreate(Bundle savedInstanceState) {
…

Hammad Nasir
- 2,889
- 7
- 52
- 133
0
votes
2 answers
Android SwitchPreference not working
I'm trying to retrieve the SwitchPreference's value using SharedPreferences but it isn't working. I'm using SwitchPreference so that user can turn on/off notifications, but it shows notifications no matter whatever the value is.
Here's the…

Ray J
- 44
- 3
- 9
0
votes
1 answer
How to implement functions for SwitchPreference,List Preference?
I have designed the setting page by using preference screen but i dont't know how to implement the functions in SwitchPreference and list preference.How to implement the condition by shared preference.
android.app.FragmentManager fragmentManager =…

Prabha Karan
- 1,309
- 3
- 17
- 35
0
votes
1 answer
Android - uncheck a SwitchPreference when it has been toggled on?
I essentially want to do the following:
switch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
…

user2892437
- 1,111
- 1
- 14
- 22