title: How to use preference fragment
body: <p>I have the following code for preferences named settings. I want to code what happens if l click an item lets say a list dialog and select a text size. I want the text size of all activities to be changed.</p>
  
  <p>settings.xml</p>
  
  <pre><code>    &lt;PreferenceScreen
      android:title="SETTINGS"
      android:summary="Setrings for Text        
       Size and background colour"&gt;
  
      &lt;intent
      android:targetPackage="com.ecb" 
  
  
           android:targetClass=
          "com.ecb.hymbook.Hym1"/&gt;
  
  
      &lt;/PreferenceScreen&gt;
  
  
      &lt;CheckBoxPreference
      android:key="checkbox_preference"
      android:title="@string/       
      title_checkbox_preference"
      android:summary="@string/   
      summary_checkbox_preference" /&gt;
  
     &lt;/PreferenceCategory&gt;
  
     &lt;PreferenceCategory
      android:title="@string/     
      dialog_based_preferences"&gt;
  
  
       &lt;ListPreference
      android:key="list_preference"
      android:title="@string/    
      title_list_preference"
      android:summary="@string/  
  
     summary_list_preference"
      android:entries="@array/  
  
       entries_list_preference"
      android:entryValues="@array/ 
      entryvalues_list_preference"
      android:dialogTitle="@string/
     dialog_title_list_preference" /&gt;
  
      &lt;ListPreference
      android:key="list_preference2"
      android:title="@string/ 
      title_list_preference2"
      android:summary="@string/ 
      summary_list_preference2"
      android:entries="@array/
      entries_list_preference2"
      android:entryValues="@array/
      entryvalues_list_preference2"
      android:dialogTitle="@string/
      dialog_title_list_preference2" /&gt;
  
       &lt;/PreferenceCategory&gt;
  
       &lt;PreferenceCategory
        android:title="@string/   
        launch_preferences"&gt;
  
      &lt;!-- This PreferenceScreen tag    
      serves as a screen break (similar to 
      page break
      in word processing). Like for other  
      preference types, we assign a key
      here so it is able to save and restore    
      its instance state. --&gt;
  
  
      &lt;PreferenceScreen
      android:title="@string/   
       title_intent_preference"
      android:summary="@string/
      summary_intent_preference"&gt;
  
      &lt;intent 
  
                android:action=
      "android.intent.action.
     VIEW"
          android:data="https:// 
       chat.whatsapp.com/
      0gWQdb5idAs0fmJ0eeRaLS"/&gt;
      &lt;/PreferenceScreen&gt;
  
      &lt;/PreferenceCategory&gt;
  
  
  
       &lt;/PreferenceScreen&gt;
  
  
  
        Settings Java
  
  
          public class Settings
          extends Activity {
  
          @Override
           protected void onCreate(Bundle     
           savedInstanceState) {
           super.onCreate
            (savedInstanceState);
  
         // Display the fragment as the main    
            content.
             getFragmentManager().
             beginTransaction(  )
            .replace(android.R.id.content, new     
             PrefsFragment()).commit();
  
  
  
  
          }
  
          public class PrefsFragment      
           extends     
           PreferenceFragment {
  
          @Override
           public void onCreate(Bundle    
            savedInstanceState) {
            super.onCreate
           (savedInstanceState);
  
          // Load the preferences from an      
          XML resource
          addPreferencesFromResource
         (R.xml.settings);
         }
  
  
  
  
  
  
  
  
  
  
      }
      }
  
  
  
            array.xml
  
  
  
  
  
         &lt;resources&gt;
        &lt;string-array    
        name="entries_list_preference"&gt;
        &lt;item&gt;DEFAULT&lt;/item&gt;
        &lt;item&gt;SMALL 1&lt;/item&gt;
         &lt;item&gt;SMALL 2&lt;/item&gt;
         &lt;item&gt;MEDIUM 1&lt;/item&gt;
          &lt;item&gt;MEDIUM 2&lt;/item&gt;  
         &lt;item&gt;LARGE 1&lt;/item&gt;
         &lt;item&gt;LARGE 2&lt;/item&gt;
         &lt;item&gt;EXTRA LARGE 1&lt;/item&gt;
        &lt;item&gt;EXTRA LARGE 2&lt;/item&gt;
         &lt;item&gt;EXTREMELY LARGE&lt;/item&gt;
  
         &lt;/string-array&gt;
  
       &lt;string-array name="entryvalues
        _list_preference"&gt;
      &lt;item&gt;DEFAULT&lt;/item&gt;
      &lt;item&gt;SMALL1&lt;/item&gt;
      &lt;item&gt;SMALL2&lt;/item&gt;
      &lt;item&gt;MEDIUM1&lt;/item&gt;
      &lt;item&gt;MEDIUM2&lt;/item&gt;  
      &lt;item&gt;LARGE1&lt;/item&gt;
      &lt;item&gt;LARGE2&lt;/item&gt;
      &lt;item&gt;EXTRALARGE1&lt;/item&gt;
      &lt;item&gt;EXTRALARGE2&lt;/item&gt;
      &lt;item&gt;EXTREMELYLARGE&lt;/item&gt; 
       &lt;/string-array&gt;
  
       &lt;string-array       
       name="entries_list_preference2"&gt;
      &lt;item&gt;blue&lt;/item&gt;
      &lt;item&gt;brown&lt;/item&gt;
      &lt;item&gt;gray&lt;/item&gt;
      &lt;item&gt;violet&lt;/item&gt;
  
  
      &lt;/string-array&gt;
  
       &lt;string-array name="entryvalues_
      list_preference2"&gt;
      &lt;item&gt;#ff000099&lt;/item&gt;
      &lt;item&gt;# 5F1E02 &lt;/item&gt;
      &lt;item&gt;# 333333 &lt;/item&gt;
      &lt;item&gt;# 421C52 &lt;/item&gt;
      &lt;/string-array&gt;
  
      &lt;/resources&gt;
  </code></pre>