title: EditTextPreference value only refreshed after clicking ListPreference second time
body: <p>I've been struggling with this issue for a while now so I decided to ask here what I' m doing wrong. </p>
  
  <p>First of all:
  - I have a PreferenceFragment with a ListPreference on top and an EditTextPreference below
  - The ListPreference is filled with Objects, the values are stored in a file and read from there (this works flawlessly)
  - The EditTextPreference should display the value of the in the ListPreference chosen object. And that's the problem: after choosing the value nothing changes so I have to click the ListPreference once more and the value is set correctly. Is this a problem with my Listener?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>public class SettingsTestFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
  
      private final String[] pref_key_array = {"pref_key_lp", "pref_key_et""}; // array that contains all the preference keys of changeable values
      private final int numberOfEntries = pref_key_array.length;
      private Preference[] pref_entries;
      String[] entries = {"Value 1", "Value 2", "Value 3"};
      String[] entryValues = {"0", "1", "2"};
      private int position;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          addPreferencesFromResource(R.xml.settings);
          final SharedPreferences myPreference = PreferenceManager.getDefaultSharedPreferences(getActivity());
  
          final EditTextPreference et = (EditTextPreference) findPreference("pref_key_et");
          final ListPreference lp = (ListPreference) findPreference("pref_key_lp");
          prepareListPref(lp);
          pref_entries = new Preference[numberOfEntries];
          for(int i = 0; i &lt; numberOfEntries; i++) {
              pref_entries[i] = getPreferenceScreen().findPreference(pref_key_array[i]);
          }
  
  
          lp.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
              @Override
              public boolean onPreferenceClick(Preference preference) {
                  position = Integer.valueOf(myPreference.getString("pref_key_lp", "0"));
                  et.setText(entries[position]);
                  return true;
              }
          });
  
  
          Preference.OnPreferenceChangeListener changeListener = new Preference.OnPreferenceChangeListener() {
              public boolean onPreferenceChange(Preference preference, Object newValue) {
                  position = Integer.valueOf(myPreference.getString("pref_key_lp", "0"));
                  preference.setSummary(entries[position]);
                  return true;
              }
          };
           lp.setOnPreferenceChangeListener(changeListener);
      }
  
      public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
         updateSummary(key, pref_key_array, numberOfEntries, pref_entries);
      }
  
  
      @Override
      public void onResume() {
          super.onResume();
          // Set up listener when a key changes
          for(int i = 0; i &lt; numberOfEntries; i++) {
              updateSummary(pref_key_array[i], pref_key_array, numberOfEntries, pref_entries);
          }
          getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
      }
  
      @Override
      public void onPause() {
          super.onPause();
          // Unregister listener every time a key changes
          getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
      }
  
      public void prepareListPref(ListPreference lp) {
          lp.setEntries(entries);
          lp.setEntryValues(entryValues);
          lp.setDefaultValue("0");
      }
  
      public void updateSummary(String key, String[] pref_key_array, int numberOfEntries, Preference[] pref_entries) {
          for(int i = 0; i &lt; numberOfEntries; i++) {
              if(key.equals(pref_key_array[i])) {
                  if(pref_entries[i] instanceof EditTextPreference) {
                      final EditTextPreference currentPreference = (EditTextPreference) pref_entries[i];
                      pref_entries[i].setSummary(currentPreference.getText());
                  } else if(pref_entries[i] instanceof ListPreference) {
                      final ListPreference currentPreference = (ListPreference) pref_entries[i];
                      pref_entries[i].setSummary(currentPreference.getEntry());
                  }
                  break;
              }
          }
      }
  }
  </code></pre>
  
  <p>Summarizing the code for reading from the file and writing the value to the Settings works but only after clicking the ListPreference a second time. Do you have any ideas why?</p>
  
  <p>Thanks</p>