1

I have a PreferenceFragmentCompat that I populate with a call to:

setPreferencesFromResource(R.xml.settings, rootKey);

After this I have a screen with editable text and checkboxes and what not. Is it possible to add a inner PreferenceScreen after this? I have tried using addPreferencesFromResource(R.xml.additional_settings) and constructing a new PreferenceScreen in code, but I always end up with a error stating that the newly added preference element is not a PreferenceScreen. I am able to add EditTextPreferences and such, but PreferenceScreen is giving me trouble.

I am using appcompat.

Quido3
  • 131
  • 1
  • 10
  • Why you want to do that ? you can always display a dialog box. – mihir raj Feb 27 '17 at 15:37
  • I have a layout design that I am implementing. Though a dialog box could achieve the same thing, I am hoping I could match the layout design. – Quido3 Feb 27 '17 at 15:44
  • Implement custom prefscreen is a last option . – mihir raj Feb 27 '17 at 15:46
  • My PreferenceScreen already uses a custom layout file and has custom DialogPreferences, so what do you mean with a custom preferencescreen? My Fragment extends a PreferenceFragmentCompat, but I am unable to add a inner PreferenceScreen to it in code, but through XML it works. – Quido3 Feb 27 '17 at 15:52
  • I think you should read this http://stackoverflow.com/questions/32487206/inner-preferencescreen-not-opens-with-preferencefragmentcompat – mihir raj Feb 27 '17 at 16:19
  • I have read that before. That is regarding the issue that the PreferenceScreens fo not open. I have a PreferenceScreen containing PreferenceScreens that open, but I have defined them in the XML. If I try to create them in code, I get an error saying they are not instances of PreferenceScreen. – Quido3 Feb 28 '17 at 07:36

0 Answers0