Understanding the Android Preferences Framework
One outstanding quality of the Android preferences framework is the simplicity of developing a screen that allows users to modify their preferences. Most of the heavy lifting is done for you by Android because developing a preferences screen is as simple as defining it in the XML located in the res/xml
folder of your project. Though these XML files aren’t the same as layout files, there are specific XML definitions that define screens, categories, and actual preferences. Common preferences that are built into the framework include
EditTextPreference
: Stores plain text as a string
CheckBoxPreference
: Stores a Boolean value
RingtonePreference
: Allows the user to store a preferred ringtone from those available on the device
ListPreference
: Allows the user to select a preferred item from a list of items in the dialog box
If the built-in preferences don’t suit your needs, you can create your own preference by deriving it from the base Preference
class or DialogPreference
. A DialogPreference
is the base class for preferences that are dialog-box-based. ...
Get Android Application Development For Dummies, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.