Settings is the portal for Android system settings. The main interface is composed of Settings.java and Settings_headers.xml.
The settings class inherits from Preferenceactivity, and Preferenceactivity inherits from Listactivity,listactivity member variables that have listview and ListAdapter types.
1. How to build a page using preferenceactivity
Using Addpreferencesfromintent or Addpreferencesfromresource will define the contents of the headers (if loaded from resource, The file that is usually placed under the XML folder) is loaded into the preferenceactivity. Each defined header is a row of view in the ListView, of course, the displayed style will be different, such as the category title "Wireless and Network" and the following "WLAN" is actually a header.
Similar to the use of a ListView, we can use additional layout files to customize the UI for each row in the ListAdapter GetView method. For example, Wi-Fi and BT have switches, then use the layout of the Perference_header_switch_item.xml to build the view.
The internal properties of the system are used when constructing various page components, such as Holder.title = (TextView) View.findviewbyid (com.android.internal.r.id.title);
Each header corresponds to a fragment, which is specified in Settings_headers.xml using a label, such as android:fragment= "Com.android.settings.wifi.WifiSettings"
2, switching (switch) processing
To the WLAN switch example, in the settings will build Wifienabler instance, the instance switch to Wifienabler, the subsequent switch state maintenance, click event Monitoring all to Wifienabler to deal with.
3, set the value of the storage
in Settings's OnCreate function, the getsharedpreferences is present, so the set value is stored in the /data/data/com.android.settings/shared_prefs "under the Com.android.settings_preferences.xml.