I've a settings fragment which load a xml with a default settings page, I also added one click listener to one specific preference
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.settings);
preferences.findPreference(getString(R.string.pref_custom_list)).setOnPreferenceChangeListener(this);
//other stuff.....
this works fine, when user clicks triggers an event and i can check some info about the switch including deny the change...
But i would like to turn on/off other switches in the same screen when this even happen
i tried to
preferences.findPreference(getString(R.string.xpto)).setEnabled(true);
but it doesn't turn any switch on or off... it just set the view enabled or disabled for clicks
if i do something like
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("xpto",true).apply();
It does change the preference, but the changes are not loaded to the screen so user doesn't know
how can i switch some preference on or off programatically and make it reflect to the preference screen