Can I load preferences.xml without extending PreferenceActivity? I need this because:
- I w开发者_开发技巧ant custom title bar
- I want all of my Activities to extend my AbstractActivity
I don't think that its very easy, and can't test it right now, but technically it should be possible...
You should use PreferenceManager that has a createPreferenceScreen(Context ctx) method that (obviously) returns a PreferenceScreen, which, according to docs:
Represents a top-level Preference that is the root of a Preference hierarchy. A PreferenceActivity points to an instance of this class to show the preferences.
And this class in turn has a getView(View convertView, ViewGroup parent) method that returns a View, and according to docs:
Gets the View that will be shown in the PreferenceActivity.
So I suppose that setting this returned View in your activity should display the same as the PreferenceActivity...
You can re-implement PreferenceActivity in your own activity class. Here's the source code of PreferenceActivity class.
It's rather small, so I don't think it'll be difficult to understand it.
加载中,请稍侯......
精彩评论