Preferences for Android (4) Organizational preferences

Source: Internet
Author: User

What is organizational preferences? It is actually the first option group!

After grouping, our homepage only displays the group name. When we click in, the list of specific preferences is displayed.

Code:

<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <preferencescreen <br/> xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Key = "edittext_screen" <br/> Android: title = "screen title" <br/> Android: Summary = "Brief description" <br/> <! -- First group --> <br/> <preferencescreen <br/> xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Key = "edittext_screen" <br/> Android: title = "group 1" <br/> Android: Summary = "click to enter group 1 Preferences" <br/> </P> <p> <ringtonepreference <br/> Android: key = "ringtonepreference" <br/> Android: Summary = "Brief description" <br/> Android: Title = "Select system ringtone" <br/> Android: ringtonetype = "alarm" <br/> Android: showsilent = "true" <br/>> <Br/> </ringtonepreference> <br/> </preferencescreen> </P> <p> <! -- The second group --> <br/> <preferencescreen <br/> xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Key = "edittext_screen" <br/> Android: title = "group 2" <br/> Android: Summary = "click to enter group 2 preference" <br/> <edittextpreference <br/> Android: dialogtitle = "enter your name:" <br/> Android: Key = "edittitlepreference" <br/> Android: Summary = "Brief description" <br/> Android: title = "input name" <br/> </edittextpreference> <br/> </P Referencescreen> </P> <p> <! -- Group 3 --> <br/> <preferencescreen <br/> xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Key = "edittext_screen" <br/> Android: title = "group 3" <br/> Android: Summary = "click to enter group 3 preference" <br/> <edittextpreference <br/> Android: dialogtitle = "enter your name:" <br/> Android: Key = "edittitlepreference" <br/> Android: Summary = "Brief description" <br/> Android: title = "input name" <br/> </edittextpreference> <br/> </preferencescreen> </P> <p> </preferencescreen> <br/>

The above method is suitable for a large number of preferences.

What if we still want to group A small number of preferences for them?

We can change the nested preferencescreen in the above Code to preferencecategory, which is so simple !!!

<? XML version = "1.0" encoding = "UTF-8"?> <Br/> <preferencescreen <br/> xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Key = "edittext_screen" <br/> Android: title = "screen title" <br/> Android: Summary = "Brief description" <br/> <! -- First group --> <br/> <preferencecategory <br/> xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Key = "edittext_screen" <br/> Android: title = "group 1" <br/> Android: Summary = "click to enter group 1 Preferences" <br/> </P> <p> <ringtonepreference <br/> Android: key = "ringtonepreference" <br/> Android: Summary = "Brief description" <br/> Android: Title = "Select system ringtone" <br/> Android: ringtonetype = "alarm" <br/> Android: showsilent = "true" <br />>< Br/> </ringtonepreference> <br/> </preferencecategory> </P> <p> <! -- Group 2 --> <br/> <preferencecategory <br/> xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Key = "edittext_screen" <br/> Android: title = "group 2" <br/> Android: Summary = "click to enter group 2 preference" <br/> <edittextpreference <br/> Android: dialogtitle = "enter your name:" <br/> Android: Key = "edittitlepreference" <br/> Android: Summary = "Brief description" <br/> Android: title = "input name" <br/> </edittextpreference> <br/> </Preferencecategory> </P> <p> <! -- Group III --> <br/> <preferencecategory <br/> xmlns: Android = "http://schemas.android.com/apk/res/android" <br/> Android: Key = "edittext_screen" <br/> Android: title = "group 3" <br/> Android: Summary = "click to enter group 3 preference" <br/> <edittextpreference <br/> Android: dialogtitle = "enter your name:" <br/> Android: Key = "edittitlepreference" <br/> Android: Summary = "Brief description" <br/> Android: title = "input name" <br/> </edittextpreference> <br/> </preferencecategory> </P> <p> </preferencescreen> <br/>

This is a big change:

 

 

 

 

 

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.