PreferenceFragment with support library
The appcompat v7 library actually uses the v4 support library, so you need to explicitly import the v7 support library components that you need.
In your case, you just need to add compile 'com.android.support:preference-v7:23.1.1'
to your build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:preference-v7:23.1.1'
}
Then this will work:
import android.os.Bundle;
import android.support.v7.preference.PreferenceFragmentCompat;
import android.view.View;
public class MyPreferenceFragment extends PreferenceFragmentCompat {
public MyPreferenceFragment() {
// Required empty public constructor
}
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.fragment_settings_pref);
}
}