Android switching between PreferenceScreens

时间秒杀一切 提交于 2019-12-06 15:43:30

Preference subscreen is displayed as a dialog, in your case it would be enough to dismiss the dialog representing appropriate PreferenceScreen. Insert the following snippet into onPreferenceClick() method of OnPreferenceClickListener you probably set for "second" and "third" preferences to close the dialog:

PreferenceScreen ps = (PreferenceScreen)PrefsActivity.this.getPreferenceScreen()
    .findPreference("subScreen");
ps.getDialog().dismiss();

where PrefsActivity is the enclosing instance of PreferenceActivity that is used in your application.

I have no idea why you have bare Preference elements in the first place. Off the top of my head, I cannot think of anywhere in Settings where the user would encounter your desired behavior, so what you are trying to do is likely to be unexpected. Also, I recommend you start to move away from nested PreferenceScreen elements, as the new direction is PreferenceFragments for Honeycomb onward.

That being said, try setPreferenceScreen() on PreferenceActivity and see if it gives you what you need.

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