title: Create Class to instantiate PreferenceFragment
body: <p>I have an app with fragments. I’m having trouble getting the PreferenceFragment to work.One of the fragments is a settings page. For this I wish to use PreferenceFragment however I have developed my app using android.support.v4.app.FragmentManager which is not compatible with PreferenceFragment. The link below has a description and link to code that will work with v4.</p>
  
  <p><a href="https://github.com/codepath/android_guides/wiki/Settings-with-PreferenceFragment" rel="nofollow">https://github.com/codepath/android_guides/wiki/Settings-with-PreferenceFragment</a></p>
  
  <p><a href="https://github.com/kolavar/android-support-v4-preferencefragment" rel="nofollow">https://github.com/kolavar/android-support-v4-preferencefragment</a></p>
  
  <p>My MainActivity</p>
  
  <pre><code>private class CustomAdapter extends FragmentPagerAdapter {
  
  private String fragments [] = {"Event","Gallery","Match","Settings"};
  
  public CustomAdapter(FragmentManager supportFragmentManager, Context applicationContext) {
      super(supportFragmentManager);
  }
  
  @Override
  public Fragment getItem(int position) {
      switch (position){
          case 0:
              return new event();
          case 1:
              return new gallery();
          case 2:
              return new match();
          case 3:
              return new PreferenceFragment();
          default:
              return null;
      }
  }
  </code></pre>
  
  <p>error: 'PreferenceFragment' is abstract, cannot be instantiated.</p>
  
  <p>PreferenceFragment</p>
  
  <pre><code>public abstract class PreferenceFragment extends Fragment implements
          PreferenceManagerCompat.OnPreferenceTreeClickListener {
  
      private static final String PREFERENCES_TAG = "android:preferences";
  </code></pre>
  
  <p>I’m told I can't instantiate a PreferenceFragment directly, I have to create a class that extends it. Could someone explain how I would go about doing that in this case? Thanks a million! :-)</p>