Download preferences.xml without extension PreferenceActivity

Can I load preferences.xml without the PreferenceActivity extension? I need this because:

  • I need a custom title bar
  • I want all my actions to expand my AbstractActivity.
+4
source share
2 answers

I don’t think it is very easy and cannot check it right now, but technically it should be possible ...

You should use a PreferenceManager that has a createPreferenceScreen(Context ctx) method that (obviously) returns a PreferenceScreen , which, according to the 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 preferences.

And this class, in turn, has a getView(View convertView, ViewGroup parent) method that returns a View , and according to the docs:

Gets the view that will be displayed in the PreferenceActivity.

Therefore, I believe that setting this returned view in your activity should display just like PreferenceActivity ...

+3
source

You can PreferenceActivity in your activity class. Here is the source code for the PreferenceActivity class.

This is quite small, so I do not think it will be difficult to understand.

+2
source

Source: https://habr.com/ru/post/1340172/


All Articles