I created a layout (preferences.xml) in the res / xml directory based on the PreferenceScreen.
Implemented a class derived from PreferencesFragmentCompat
public class PrefsFragment extends PreferenceFragmentCompat
{
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.preferences, rootKey);
}
}
Implemented the preferences activity
public class PrefsActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.prefs_activity);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragContent, new PrefsFragment());
transaction.commit();
}
}
When I run the activity the following error is displayed:
java.lang.RuntimeException: Unable to start activity ComponentInfo {PrefsActivity}: java.lang.IllegalStateException: Must specify preferenceTheme in theme
How do I specify the preferenceTheme ?