I have a PreferenceScreen that is defined in XML that serves all the preferences for my application. This PreferenceScreen also has a child PreferenceScreen nested within it. My implementing class is called PreferencesActivity. I know I can open the main Preferences window via startActivity(new Intent(this, PreferencesActivity.class)); but how do I go about opening the child PreferenceScreen via an Intent?
Asked
Active
Viewed 6,361 times
2 Answers
4
i researched a while on this topic for my project Theft Aware (http://www.theftaware.com) (a little bit advertisement... :-) and i found the solution:
PreferenceScreen screen = getPreferenceScreen(); // gets the main preference screen
screen.onItemClick(null, null, INDEX , 0); // click on the item
where INDEX is the position of the item you want to open on the screen
-
Thank you very much!!! I am wondering if this can be adapted to make the positioning of the items agnostic. – Mike Jul 01 '10 at 11:44
-
1I've implemented the method by Reinhard to solve it more generally, see the link in my answer to my question! – Markus Feb 02 '11 at 11:51
3
see this question for a more general solution based on Reinhard's idea, finally!
-
Works, but if you're using PreferenceCategories be sure to read down for the code by deepak patel and use that, otherwise 'getOrder' will not work – Carlos P Mar 18 '15 at 18:11