Questions tagged [switchpreference]

51 questions
2
votes
1 answer

How to Change text summary color on SwitchPreference

I created a Setting by using PreferenceFragmentCompat public class SettingsFragment extends PreferenceFragmentCompat { @Override public void onCreatePreferences(Bundle bundle, String s) { …
Nanda Z
  • 1,604
  • 4
  • 15
  • 37
2
votes
1 answer

Android id for the custom layout for SwitchPreferenceCompat

I have been trying to create custom layouts to style fonts for Preference(s) in a PreferenceFragment. For simple preferences with only title and a summary, I have been able to do so by mentioning a layout resources with android id(s) like:
Swapnil
  • 1,870
  • 2
  • 23
  • 48
2
votes
2 answers

Android v14 SwitchPreference not changing values

Class file import android.support.v14.preference.SwitchPreference; //... @Override public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { addPreferencesFromResource(R.xml.pref_blank); this.preferenceScreen =…
CamHart
  • 3,825
  • 7
  • 33
  • 69
2
votes
1 answer

How to change icon of SwitchPreference when it changes state from off to on?

I would like to change the icon in my SwitchPreference (e.g. for enabling notification sound) once the state is changed from on to off and vice versa. This is the code of my SwitchPreference:
APagano
  • 108
  • 5
2
votes
1 answer

How to show changed SwitchPreference value after AlertDialog click

I have a SwitchPreference that displays AlertDialog onChange and would like to accept/reject the change depending on button clicked in AlertDialog (positive/negative). If user attempts to change value to "true" the change should be accepted,…
1
vote
1 answer

change to dark mode in settingsFragment in kotlin

I would like to do a small upgrade of my application and I would like the theme to change to dark mode after pressing SwitchPreference. I need a detailed guide or someone to explain to me exactly how to do it. If I am just learning to do something…
1
vote
0 answers

Accessible mode repeating

I load different layouts when SwitchPreference is turned on and off, and summay has a countdown when it is turned on, but when I turn on Accessible mode, the words on the countdown screen refresh, causing repeated broadcasts. I use…
xy f
  • 11
  • 1
1
vote
1 answer

How to change and save switch preference summary

So I recently joined the Kotlin train, and I have a fragment which changes the theme of my android app, I made the fragment restart after successfully switching theme, and then from the MainActivity reopen the fragment using a bundle set earlier in…
Kennedy
  • 547
  • 4
  • 23
1
vote
1 answer

SwitchPreference in pre Android 7 always switched off

I'm extending PreferenceFragmentCompat, in the onCreatePreferences method the preference are set using addPreferencesFromResource(R.xml.preferences).
Jules
  • 189
  • 1
  • 5
  • 20
1
vote
0 answers

How to Bind Data to Android Preference

I want to have a custom SwitchPreference layout and pass the "title" parameter to it, similar to this:
Elliptica
  • 3,928
  • 3
  • 37
  • 68
1
vote
0 answers

SwitchPreference and Switch

I have a custom switch control class MySwitch public class MySwitch extends RelativeLayout implements CompoundButton.OnCheckedChangeListener { //private final Context context; private String swKey; private Integer swIcoOn, swIcoOff; Switch…
1
vote
1 answer

NullPointerException upon tap on SwitchPreference

I get my app force close when I tap anywhere around the exact switch button itself. Screenshot describing this: tinypic / imgur preferences.xml
1
vote
1 answer

How to enable and disable action on switch preference in android

This is not working with switch preference please help .......to write another code.. SwitchPreference uiTestModePref = (SwitchPreference) findPreference("switch"); uiTestModePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { …
1
vote
1 answer

SwitchPreference default setting is always Off

I have a SwitchPreference: android:defaultValue="true" No matter what I try, in the preference menu, it's always…