Now do the company task, often to read settings source code, and then found in the XML file is almost entirely used in Preferencescreen and preferencecategory tags, very few useful layout and control, Then I went online to read a lot of relevant information, in this summary.
First, in the Res directory, create a new folder named XML, then create a aaa.xml file and select the resource tag.
Use Preferencecategory first, the code is as follows
1 <preferencecategoryAndroid:title= "show a row of preferences" >2 <checkboxpreference3 Android:key= "Checkbox_pre"4 android:summary= "This is a switch button"5 Android:title= "Switch Preference" />6 </preferencecategory>
:
Preferencecategory is equivalent to grouping, placing the same class of options in the same area.
Take a look at Preferencescreen, the code is as follows
1 <Preferencescreen2 Android:key= "Screen_pre"3 android:summary= "Show another preference screen"4 Android:title= "Screen" >5 <checkboxpreference6 Android:key= "Next_screen_checkbox_pre"7 android:summary= "Another on-screen preference"8 Android:title= "Switch Preference" />9 </Preferencescreen>
, and then find no checkbox to show
Because Preferencescreen can be clicked in, click on the option, you can see the checkbox.
Then look at listpreference, generally embedded in the preferencescreen used, looks comfortable, the code is as follows
<PreferencescreenAndroid:title= "dialog-based preferences" > <listpreferenceAndroid:dialogtitle= "Select one"android:entries= "@array/auto_update_frequency_entry"android:entryvalues= "@array/auto_update_frequency_value"Android:key= "List_pre"android:summary= "Use a list dialog box"Android:title= "List Preference" > </listpreference></Preferencescreen>
Clicking on the screen,listpreference will pop up like Dialog,
Android:entries and Android:entryvalues Two properties of the value source:
Create a array.xml in the values directory
<?XML version= "1.0" encoding= "Utf-8"?><Resources> <String-arrayname= "Auto_update_frequency_entry"> <Item>10 minutes</Item> <Item>30 minutes</Item> <Item>1 hours</Item> <Item>12 hours</Item> <Item>24 hours</Item> </String-array> <String-arrayname= "Auto_update_frequency_value"> <Item>10</Item> <Item>30</Item> <Item>60</Item> <Item>720</Item> <Item>1440</Item> </String-array></Resources>
I'm probably going to get to know this right now.
Use of preference tags in android