And Now, a Word from Our Framework
Beginning with the 0.9 SDK, Android has a framework for managing preferences. This framework does not change anything mentioned previously. Instead, the framework is more for presenting consistent preference‑setting options for users so different applications do not have to reinvent the wheel.
The linchpin to the preferences framework is yet another XML data structure. You can describe your application’s preferences in an XML file stored in your project’s directory. Given that, Android can present a pleasant UI for manipulating those preferences, which are then stored in the you get back from .
The following is the preference XML for the preferences sample project available in the Source Code section at http://apress.com:
The root of the preference XML is a element. (I will explain why it is named that later in this chapter; for now, take it on faith that it is a sensible name.) One of the things you can have inside a element, not surprisingly, is preference definitions – subclasses of , such as or , as shown in the preceding code. As one might expect, these allow you to check a checkbox and choose a ringtone, respectively. In the case of , you have the option of allowing users to choose the system‑default ringtone or to choose “silence” as a ringtone.
Дата добавления: 2015-05-16; просмотров: 723;