Android Apidemos Sample Resolution (a) App->preferences->preferences from XML

Source: Internet
Author: User

In the previous example of Android Apidemo example parsing (9): App->activity->persistent state describes the use of shared preferences to store some states, shared A more general use of preferences is to store some application preferences (settings). Package Android.preference provides many classes that allow applications to display and set application-related preferences. Of course, you can use a custom UI to configure these program preferences. But using classes defined in Android.preference can give users a unified UI (consistent with the settings of Android itself).

Typically, program preferences are performed using separate activity (derived from preferenceactivity). In Preferenceactivity, Preferencescreen is the root element of layout, which can contain other such as: Checkboxpreference, Edittextpreference, Listpreference, Preferencecategory or ringtonpreference. When using preference, all program preferences are automatically saved in the application's sharedpreferences, and applications can access these preferences through Getsharedpreferences ().

Checkboxpreference uses a checkbox to display a configuration item.

Edittextpreference uses a text box to display a sign item that allows you to accept user input text.

Listpreference use a set of radio buttons (lists) from which you can select an item.

Multiselectlistpreference uses a set of checkbox to allow the configuration item to have multiple values.

Ringtonpreference allows the user to select a ringtone from

The base class for these classes is preference, it is a base class, and you can define a custom preference.

Preferencegroup can define a group for multiple preference, preferencecategory, Preferencescreen for its subclasses.

Preferencecategory can also contain multiple preferneces, which can provide a title if the group is disable.

Preferencescreen is the root element of the preferences hierarchy, Preferencescreen can be nested. The inner Preferencescreen will use a new on-screen display, somewhat similar to the paging functionality in Word.

Preferences from XML describes using XML to define application preferences, and uses preferenceactivity to display this preference.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.