Advantages of PreferenceActivity
-
14-10-2019 - |
Question
When adding a "settings" screen to my app I seem to have come up with two choices:
use the PreferenceActivity that is given by Android
create a standard Activity that saves all the user's choices
Assuming I don't mind writing the code that saves the preferences (a relatively trivial task), what other advantages are there to using a PreferenceActivity? If anything, using a standard Activity provides much more flexibility with regards to UI design.
Solution
You are right, given the desired view complexity (which sometimes is not more usable - remember preferences should be easy to set), it might not make sense to implement a PreferenceActivity
. The idea is to present a uniform configuration screen & visual style to the user. As such, a user will always know when he entered a preference screen.
From the docs:
Furthermore, the preferences shown will follow the visual style of system preferences. It is easy to create a hierarchy of preferences (that can be shown on multiple screens) via XML. For these reasons, it is recommended to use this activity (as a superclass) to deal with preferences in applications.
The docs say something about inflated views, maybe you could investigate whether complex layouts or custom views can be integrated.