How to open a nested child PreferenceScreen in Android

巧了我就是萌 提交于 2019-12-13 13:07:10

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/2870851/how-to-open-a-nested-child-preferencescreen-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!