Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a nested child PreferenceScreen in Android

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?

like image 201
Mike Avatar asked May 20 '10 03:05

Mike


2 Answers

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

like image 158
Reinhard Avatar answered Nov 19 '22 17:11

Reinhard


see this question for a more general solution based on Reinhard's idea, finally!

like image 21
Markus Avatar answered Nov 19 '22 18:11

Markus