JJ Ab
JJ Ab

Reputation: 502

Android Transaction with PreferenceFragment

I'm using a FragmentTransaction to replace a fragment in a container like this:

activity.getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.abc_fade_in, R.anim.abc_fade_out).replace(R.id.container, fragmentToShow).addToBackStack(null).commit();

The problem is that a PreferenceFragment can not be converted to support v4 fragment. How can I use a PreferenceFragment like that?

Upvotes: 1

Views: 1750

Answers (1)

Federico Falcone
Federico Falcone

Reputation: 81

I did the same problem and I solved in those steps:

  1. Add to gradle file dependencies this line
    compile 'com.android.support:preference-v7:23.3.0'
  2. Extends your SettingFragment with
    'PreferenceFragmentCompat'
  3. Import in your class
    import android.support.v7.preference.PreferenceFragmentCompat;

Upvotes: 8

Related Questions