android4.2.2 Settings

来源:互联网 发布:阿里云香港ss 编辑:程序博客网 时间:2024/04/29 05:14

 

出自 :http://blog.csdn.net/abc137508277/article/details/8878885

Setting分析

Setting的启动要从setting.java中分析。为topactivity extends PreferenceActivity

PreferenceActivity英语文档

This activityshows one or more headers of preferences, each of which is associated with a PreferenceFragment to display the preferences of that header. The actuallayout and display of these associations can however vary; currently there aretwo major approaches it may take:

·        On a small screen it may display only the headers as asingle list when first launched. Selecting one of the header items willre-launch the activity with it only showing the PreferenceFragment of thatheader.

·        On a large screen in may display both the headers andcurrent PreferenceFragment together as panes. Selecting a header item switchesto showing the correct PreferenceFragment for that item.

以上意思翻译过来就是说,preferrenceActivity可以显示1个或者多个header。每个header都是以PreferenceFragment显示。

PreferenceActivity显示也分两种,

一种是在小的屏幕上,或者低分辨率设备上,只显示header部分。点击header进入fragment。

另外一种是在大的屏幕上或者高分辨率设备上,header和fragment同时显示,左侧是header,右侧是fragment.

在onBuildHeaders加载主界面

loadHeadersFromResource(R.xml.settings_headers,headers);

其中addPreferencesFromResource methodwas deprecated in API level 11

各个fragment是依附于subsetting的,由subsetting统一管理各个fragment。相当于一个activity在多个UI界面之间的切换。

其设置里面的Google Account有个location setting,这个东西是在GoogleServicesFramework.apk中添加的。没有源码,这个是google服务框架。

转载请注明出处,thanks!