title: How to go from an Activity to PreferenceFragment?
body: <p>I am having trouble navigating from my main page which is an <code>Activity</code> to the account settings page which uses <code>PreferenceFragment</code>. </p>
  
  <p>I'm trying to achieve this via the navigation drawer, when the item is clicked, the settings page should be displayed. All my other pages are a <code>Fragment</code> except the account settings page and all work properly (except for the settings page). I thought <code>PreferenceFragment</code> extends from <code>Fragment</code> so surely it should work?</p>
  
  <p><strong>MainPage.java</strong></p>
  
  <pre><code>@Override
  public void onNavigationDrawerItemSelected(int position) {
      // update the main content by replacing fragments
      FragmentManager fragmentManager = getSupportFragmentManager();
      if (position == 0) {
          fragmentManager.beginTransaction()
                  .replace(R.id.container, PlaceholderFragment.newInstance(1))
                  .commit();
  
      } else if (position == 1) {
          fragmentManager.beginTransaction()
                  .replace(R.id.container, Search.newInstance(2))
                  .commit();
  
      }
  
      else if (position == 2) {
          fragmentManager.beginTransaction()
                  .replace(R.id.container, Favourites.newInstance(3))
                  .commit();
      }
  
      else if (position == 3) {
          fragmentManager.beginTransaction()
                  .replace(R.id.container, History.newInstance(4))
                  .commit();
  
      }
  
      else if (position == 4) {
          fragmentManager.beginTransaction()
                  .replace(R.id.container, AccountSettings.newInstance(5))
                  .commit();
  
      }
  
  }
  </code></pre>
  
  <p><strong>AccountSettings.java</strong></p>
  
  <pre><code>public class AccountSettings extends PreferenceFragment {
  
      Activity mActivity;
  
      private static final String ARG_SECTION_NUMBER = "section_number";
  
      public static AccountSettings newInstance(int sectionNumber) {
          AccountSettings fragment = new AccountSettings();
          Bundle args = new Bundle();
          args.putInt(ARG_SECTION_NUMBER, sectionNumber);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);    //inflating layout
          addPreferencesFromResource(R.xml.settings);
          setHasOptionsMenu(true);
          restoreActionBar();
  
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          mActivity = activity;
  
      }
  
      public void restoreActionBar() {
          ActionBar actionBar = ((AppCompatActivity)getActivity()).getSupportActionBar();
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
          actionBar.setDisplayShowTitleEnabled(true);
          actionBar.setTitle("Account Settings");
      }
  
      public AccountSettings() {
  
      }
  }
  </code></pre>
  
  <p>It would give me the following error on <strong>MainPage.java</strong>:</p>
  
  <pre><code>'replace(int, android.support.v4.app.Fragment)' in 'android.support.v4.app.FragmentTransaction' cannot be applied to '(int, com.example.laptop.whatsfordinner.AccountSettings)'
  </code></pre>
  
  <p>I've tried changing it to a <code>Fragment</code> and it works, but I want to use <code>PreferenceFragment</code>, so how can I get it to work?</p>
  
  <p>Surely I'm just missing something really obvious?</p>