2

How to use preference fragment with android.support.v4.app.Fragment? I tried to use android.preference.PreferenceFragment but I got an error: Wrong 2nd argument type/

FragmentTransaction transaction = getFragmentManager().beginTransaction();
            transaction.replace(R.id.fragment_container, new SettingsFragment());
            transaction.addToBackStack(null);
            transaction.commit();

SettingsFragment is the preference fragment

What can solve this problem?

Hadar Shavit
  • 107
  • 1
  • 11

1 Answers1

1

By my knowledge PreferenceFragment is not supported in the android.support.v4 library.

You can however use PreferenceFragmentCompat from the support-v7 library.

If it really has to work with the support-v4 library, I would recommend adding the following project as a library project to your application as suggested by this old thread.

https://github.com/kolavar/android-support-v4-preferencefragment

Community
  • 1
  • 1
jbrulmans
  • 975
  • 1
  • 11
  • 32