Note that nested PreferenceScreen elements haven't looked good on
Honeycomb when I've tried them. You may also wish to consider how you
will approach this when you switch to PreferenceFragments going
forward.

On Sat, Jul 2, 2011 at 9:18 AM, Phil H <[email protected]> wrote:
> Yes, the first two options are a bit unpleasant, and as for the third, well
> its an option but I couldn't help feeling there had to be a better way.
> After some more thought I ended up adopting a slightly different approach
> altogether. I took out the two mutually exclusive sets of preferences and
> put them in two other preference files, 'a' and 'b'. Then I created a
> separate, new preference activity (MorePreferences, below) that in the
> onCreate method loaded 'a' or 'b' based on my checkbox preference value:
>
> public void onCreate(final Bundle savedInstanceState) {
>
>
>
> super.onCreate(savedInstanceState);
>
>
>
> final int preferences;
> if (Preferences.isPreferencesA(this)) {
>
>         preferences = R.xml.
>
> }
>
> else {
>
>     preferences = R.xml.
>
> }
>
> addPreferencesFromResource(preferences);
>
> }
>
> In the main preferences I put a PreferenceScreen entry in, which uses an
> intent to fire up the new preference activity - when activated it loads the
> right set of preferences:
>
> <PreferenceScreen android:title="@string/announcement_settings"
> android:summary="@string/announcement_settings_summary">
>
> <intent
>
>     android:action="android.intent.action.MAIN"
>
>     android:targetPackage="mypackage"
>
>     android:targetClass="mypackage.MorePreferences"/>
>
> </PreferenceScreen>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 3.5 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to