开发者

Android Preferences - changing the order in which they appear

I'm trying to create a hierarchy of classes which start with a PreferenceActivity.

The idea is the base class contains the 'About Me' button, then the next class implements the generic preferences for games/apps/wallpapers and then the next class adds the the specifics for each actual Game/App.

The idea works well BUT because I'm 'adding' preferences from XML at each level, they appear with the most generic (lowest level) ones first (e.g. my 'About' button).

Ideally I'd like them to be the other way up - so that specific preferences appear at the top of the list and generic ones at the bottom - is there any way of achieving this (I've read through the docs on PreferenceFragments and the new PreferenceHeaders and even that doesn't seem to offer anything?)

Is there any programmatic way to move PreferenceCategorys or PreferenceScreens around within the overall order??

Essentially when I'm using

addPreferencesFromResource(R.xml.clock_settings)开发者_如何学编程;

I'd like to have a

addPreferencesFromResourceAtBottom(R.xml.clock_settings);


I'm getting good at answering my own questions here :)

The solution lies in the android:order XML parameter - using that with Preference (or PreferenceGroup or a sub-class of it) will sort stuff into the right sequence on screen!

You could also change this dynamically with setOrder() but it won't reorder the Preferences if they've already been added to a PreferenceGroup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜