setting-在设置中添加新的选项
如下图的“通知栏调出方式”

具体实现如下
1.在
res/xml/settings_headers.xml
文件中添加如下内容
<preference-headers
xmlns:android="http://schemas.android.com/apk/res/android">
<header
android:id="@+id/quick_pulldown"
android:fragment="com.android.settings.QuickPullDown"
android:title="@string/quick_pulldown"
android:icon="@drawable/ic_quick_pulldown" />
</preference-headers>
2.关联的fragment类如下
public class QuickPullDown extends SettingsPreferenceFragment implements
OnPreferenceClickListener { private Context mContext; private AudioProfilePreference mOffPressPref;
private AudioProfilePreference mRightPressPref;
private AudioProfilePreference mLeftPressPref;
private static final int QS_QUICK_PULLDOWN_DEFAULT_VALUE = 0;
private static final String OFF = "off";
private static final String RIGHT = "right";
private static final String LEFT = "left"; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getActivity();
addPreferencesFromResource(R.xml.quick_pulldown); mOffPressPref = (AudioProfilePreference) findPreference(OFF);
mRightPressPref = (AudioProfilePreference) findPreference(RIGHT);
mLeftPressPref = (AudioProfilePreference) findPreference(LEFT);
mOffPressPref.isShowDetailsView = false;
mRightPressPref.isShowDetailsView = false;
mLeftPressPref.isShowDetailsView = false;
mOffPressPref.setOnPreferenceClickListener(this);
mRightPressPref.setOnPreferenceClickListener(this);
mLeftPressPref.setOnPreferenceClickListener(this);
refreshPressState();
} @Override
public void onResume() {
super.onResume();
getListView().setDivider(null);
getListView().setBackgroundResource(R.drawable.funui_background);
getListView().setSelector(android.R.color.transparent);
new BackgroundChooser().justDoIt(getPreferenceScreen());
} @Override
public boolean onPreferenceClick(Preference preference) {
if (preference instanceof AudioProfilePreference) {
if (preference == mOffPressPref) {
Settings.System.putInt(mContext.getContentResolver(), QS_QUICK_PULLDOWN, 0);
} else if (preference == mRightPressPref) {
Settings.System.putInt(mContext.getContentResolver(), QS_QUICK_PULLDOWN, 1);
} else if (preference == mLeftPressPref) {
Settings.System.putInt(mContext.getContentResolver(), QS_QUICK_PULLDOWN, 2);
}
refreshPressState();
}
return true;
} public void refreshPressState() {
int value = Settings.System.getInt(
getContentResolver(), QS_QUICK_PULLDOWN, QS_QUICK_PULLDOWN_DEFAULT_VALUE); mOffPressPref.setRadioButtonClickable(false);
mRightPressPref.setRadioButtonClickable(false);
mLeftPressPref.setRadioButtonClickable(false);
switch (value) {
case 0:
mOffPressPref.setChecked();
break;
case 1:
mRightPressPref.setChecked();
break;
case 2:
mLeftPressPref.setChecked();
break;
default:
break;
}
}
}
3.这个类中用到的布局文件如下
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <com.android.settings.FunuiPreferenceCategory
android:key="quick_pulldown_setting"
android:persistent="false"
android:title="@string/quick_pulldown"> <com.mediatek.audioprofile.AudioProfilePreference
android:key="off"
android:layout="@layout/funui_switch_preference_full"
android:title="@string/quick_pulldown_off"
android:summary="@string/quick_pulldown_off_describe"/> <com.mediatek.audioprofile.AudioProfilePreference
android:key="right"
android:layout="@layout/funui_switch_preference_full"
android:title="@string/quick_pulldown_right"
android:summary="@string/quick_pulldown_right_describe"/> <com.mediatek.audioprofile.AudioProfilePreference
android:key="left"
android:layout="@layout/funui_switch_preference_full"
android:title="@string/quick_pulldown_left"
android:summary="@string/quick_pulldown_left_describe"/>
</com.android.settings.FunuiPreferenceCategory> </PreferenceScreen>
这些其实就是setting这个模块的基本实现框架了
如何设定它的显示跟隐藏呢,主要是在这个
src/com/android/settings/Settings.java
类中实现的,代码如下
public void updateHeaderList(List<Header> target) {
if (id == R.id.quick_pulldown) {
target.remove(header);
}
}
setting-在设置中添加新的选项的更多相关文章
- VMware 虚拟机中添加新硬盘的方法(转载)
随着在虚拟机中存储的东西的逐渐的增加,虚拟机的硬盘也逐渐告急,因此急需拓展一块新的虚拟磁盘.以下便是在VMware 中添加新的虚拟磁盘的方法: 一.VMware新增磁盘的设置步骤 (建议:在设置虚 ...
- 详解VMware 虚拟机中添加新硬盘的方法
一.VMware新增磁盘的设置步骤 (建议:在设置虚拟的时候,不要运行虚拟机的系统,不然添加了新的虚拟磁盘则要重启虚拟机) 1.选择“VM”----“设置”并打开,将光标定位在“硬盘(SCSI)”这一 ...
- discuz 修改亮剑积分商城2.91模板(在常用设置中添加商场首页排序方式的背景颜色)
在应用 -> 积分商城 -> 常用设置 中添加 商场首页排序方式 的背景颜色修改功能 步骤: 1.找到并打开此页面对应的模板source\plugin\aljsc\template\set ...
- 在ubuntu中添加新硬盘
在ubuntu中添加新硬盘 转载于 http://www.cnblogs.com/unipower/archive/2009/03/08/1406230.html 前言 安装新硬盘这种事情并不会经常 ...
- 向CDH5集群中添加新的主机节点
向CDH5集群中添加新的主机节点 步骤一:首先得在新的主机环境中安装JDK,关闭防火墙.修改selinux.NTP时钟与主机同步.修改hosts.与主机配置ssh免密码登录.保证安装好了perl和py ...
- (原)torch7中添加新的层
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6069627.html 参考网址: http://torch.ch/docs/developer-doc ...
- gitignore文件中添加新过滤文件,但是此文件已经提交,如何解决?
gitignore文件中添加新过滤文件,但是此文件已经提交到远程库,如何解决? 第一步,为避免冲突需要先同步下远程仓库 git pull 第二步,在本地项目目录下删除缓存 git rm -r --ca ...
- C# 往Datatable中添加新行的步骤
以一个实例说明 //录入年份绑定 public void YearList(FineUIPro.DropDownList ddlYear) { //年份从15年到当前年//起止年份 ; int yea ...
- SqlServer表中添加新字段
表中添加新字段ALTER TABLE 表名 ADD 字段名 VARCHAR(20) NULL 表中添加自增idalter table lianxi add id int primary key IDE ...
随机推荐
- 6.C语言迷宫程序界面版
写迷宫程序首先需要安装图形库easyX 安装地址链接:https://pan.baidu.com/s/1qZwFn3m 密码:ozge 项目截图: //左上角是七点,右下角是终点,蓝色表示的是走过的路 ...
- Sqoop1与Sqoop2的比较
1.sqoop1和sqoop2是两个不同的版本,它们是完全不兼容的. 2.版本划分方式:Apache 1.4.x 之后的版本属于sqoop1,1.99.x之上的版本属于sqoop2. 3.与sqoop ...
- PL/SQL Developer怎么连接远程数据库
首先打开电脑,到PL/SQL安装的指定目录 [D:\app\DZL\product\10.2.0\dbhome_1\NETWORK\ADMIN]或者[D:\oracle\product\10.2.0\ ...
- AIX 压缩与归档
.tar.Z 格式 压缩: compress filename.tar 解压: zcat filename.tar.Z tar -xvf - .tar.gz 格式 压缩:t ...
- MYSQL查询数据中通讯最多的两个人
SELECT GREATEST( sender_id, recipient_id ) , LEAST( sender_id, recipient_id ) , COUNT( * ) AS aFROM ...
- 36Kr众筹项目比呀比biyabi,调查分析研究报告,背后资方势力的关系梳理
36Kr众筹项目比呀比biyabi调查报告 个层次的评价. 变革家-比呀比拆解报告:http://biangejia.com/archives/12653 8.其它 没有通过微信,参加路演,有点遗 ...
- React Native入门——IDE及其它相关基础技术
关于React Native的开发,当中一个问题是缺少好用的IDE,有些人说不就是JS么,搞一个记事本也就写了,那样尽管牛逼,但事实上还是非常头大的,有一款好的IDE还是能提升开发效率的,这里对几个还 ...
- Peer To Peer——对等网络
今年的考试.大问题没怎么出现. 就是考英语第二天的下午,发生网络阻塞的现象,不影响大局.可是事出有因,我们还是须要看看是什么影响到了考生抽题.最后查了一圈,发现其它几场的英语考试听力都是19M大小,而 ...
- DataTable填充实体类返回泛型集合
昨天找坤哥看到我的一段代码.例如以下: 略微解释下,这段代码时D层查询结束后,将datatable查询到的结果赋值给实体对象的属性,然后返回实体的过程.坤哥看了之后问我.假设实体有500多个属性.难道 ...
- RTSP、HTTP、HTTPS、SDP四种协议详解
我们将主要讲解RTSP,HTTP,HTTPS, SDP四种协议. 一:RTSP协议简介 实时流协议RTSP是一个应用层协议,用于控制具有实时特性的数据(例如多媒体流)的传送. RTSP协议一般与RT ...