Is it somehow possible to include one preferences.xml
into another, like it can be done for layouts with the <include />
tag?
Let's say:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen
android:title="@string/pref_group_title_visual">
<include
preferences_filename="xml/pref_visual"/>
</PreferenceScreen>
...
The solution soul shows works. It can be expanded to only show preferences if you're the developer using an unsigned version of the app ;)
I created a blog post regarding this issue and have a complete working code example available for download. http://androidfu.blogspot.com/2012/05/developer-debug-with-nested-preferences.html
Solution here it is to inflate both preference files from PreferencesActivity. For example:
No, it seems to be impossible. But there's a simple workaround. You can make another
PreferenceActivity
that loads nestedPreferenceScreen
. And in the main preference.xml file you need to create aPreference
object and set anIntent
object for it in code (usingsetIntent()
method). ThisIntent
must be used to create the secondPreferenceActivity
.To truly achieve the nesting effect you can use this technique to relocate the loaded preferences to a group already loaded.
Where the enhanced addPreferencesFromResource is defined as:
It works for any PreferenceGroup such as PreferenceScreen and PreferenceCategory.