title: Preference Fragment setOnPreferenceClickListener Not Working
body: <p>I am currently attempting to implement a Preference Fragment into my app and I am having trouble setting up the setOnPreferenceClickListener. It seems as if the listener is not working at all and the code is never being implemented. I simply just have a Toast in the listener for now as a test. I have browsed numerous forums and have not found a good answer thus far. Code is below. Thanks in advance!</p>
  
  <p>SettingFragment.java</p>
  
  <pre><code>public class SettingsFragment extends PreferenceFragment {
  
      private OnFragmentInteractionListener mListener;
  
      private Preference mFontPreference;
      private Preference mFontSizePreference;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          addPreferencesFromResource(R.xml.fragment_settings);
  
          mFontPreference = findPreference("font_preference");
          mFontSizePreference = findPreference("font_size_preference");
  
          mFontPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
              @Override
              public boolean onPreferenceClick(Preference preference) {
                  String key = preference.getKey();
                  Toast.makeText(getActivity(), key, Toast.LENGTH_LONG).show();
                  return true;
              }
          });
      }
  </code></pre>
  
  <hr>
  
  <p>fragment_settings.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PreferenceScreen
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="match_parent"
      android:layout_width="match_parent" &gt;
  
      &lt;PreferenceCategory android:title="Text Settings"&gt;
  
          &lt;ListPreference
              android:enabled="true"
              android:key="font_preference"
              android:title="Font"
              android:summary="Select a Font"
              android:entries="@array/font_spinner_array"
              android:entryValues="@array/font_spinner_array"/&gt;
  
          &lt;ListPreference
              android:enabled="true"
              android:key="font_size_preference"
              android:title="Font Size"
              android:summary="Select a Font Size"
              android:entries="@array/font_size_array"
              android:entryValues="@array/font_size_value_array"/&gt;
  
      &lt;/PreferenceCategory&gt;
  
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <hr>
  
  <p>arrays.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;string-array name="font_spinner_array"&gt;
          &lt;item&gt;System Font&lt;/item&gt;
          &lt;item&gt;Helvetica&lt;/item&gt;
          &lt;item&gt;Helvetica-Neue&lt;/item&gt;
          &lt;item&gt;Impact&lt;/item&gt;
      &lt;/string-array&gt;
      &lt;string-array name="font_size_array"&gt;
          &lt;item&gt;Small&lt;/item&gt;
          &lt;item&gt;Medium&lt;/item&gt;
          &lt;item&gt;Large&lt;/item&gt;
      &lt;/string-array&gt;
      &lt;string-array name="font_size_value_array"&gt;
          &lt;item&gt;1&lt;/item&gt;
          &lt;item&gt;2&lt;/item&gt;
          &lt;item&gt;3&lt;/item&gt;
      &lt;/string-array&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>EDIT:</strong>
  So the Toast wasnt working because it didnt have the .show(). That was fixed and it displays "font_preference" when clicked. The listener is working but I want to extract the value of the entry the user clicks on, not the key of the entire preference. Is there a method for doing that?</p>