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: