Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh EditText of a Preference depending on the change of another Preference
    primarykey
    data
    text
    <p>I want to change the values <strong>displayed</strong> in each <code>Preference</code> in my <code>PreferenceActivity</code> based on the change in another preference. </p> <p>I have an app that stores metric (float) values in <code>Preferences</code>. I also have a <code>Preference</code> called <code>metric</code> where the user can switch between usage of metric or imperial units. </p> <p>I only store metric values, but when the user switches to imperial the app displays the imperial values. </p> <p>Everything works fine if the user only switches the metric preference and leaves the <code>PreferenceActivity</code>. When he goes back the values are displayed the correct way. If he goes to look at <code>userHeight</code> for example the display still shows the metric value though.</p> <p>In my <code>PreferenceActivity</code> I want to refresh the displayed values when the <code>metric</code> Preference changes (I am making sure that when these values should be stored they will be converted back correctly):</p> <pre> this.metric.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { final Boolean metric = Boolean.parseBoolean(newValue.toString()); changeSummaries(metric); refreshDisplay(metric); return true; } }); </pre> <p>What do I have to implement in the <code>refreshDisplay(...)</code> method? It would also help to know at what point of the lifecycle of the <code>PreferenceActivity</code> are the changed values committed?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload