如下图的“通知栏调出方式”

具体实现如下

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-在设置中添加新的选项的更多相关文章

  1. VMware 虚拟机中添加新硬盘的方法(转载)

    随着在虚拟机中存储的东西的逐渐的增加,虚拟机的硬盘也逐渐告急,因此急需拓展一块新的虚拟磁盘.以下便是在VMware 中添加新的虚拟磁盘的方法:   一.VMware新增磁盘的设置步骤 (建议:在设置虚 ...

  2. 详解VMware 虚拟机中添加新硬盘的方法

    一.VMware新增磁盘的设置步骤 (建议:在设置虚拟的时候,不要运行虚拟机的系统,不然添加了新的虚拟磁盘则要重启虚拟机) 1.选择“VM”----“设置”并打开,将光标定位在“硬盘(SCSI)”这一 ...

  3. discuz 修改亮剑积分商城2.91模板(在常用设置中添加商场首页排序方式的背景颜色)

    在应用 -> 积分商城 -> 常用设置 中添加 商场首页排序方式 的背景颜色修改功能 步骤: 1.找到并打开此页面对应的模板source\plugin\aljsc\template\set ...

  4. 在ubuntu中添加新硬盘

    在ubuntu中添加新硬盘 转载于 http://www.cnblogs.com/unipower/archive/2009/03/08/1406230.html  前言 安装新硬盘这种事情并不会经常 ...

  5. 向CDH5集群中添加新的主机节点

    向CDH5集群中添加新的主机节点 步骤一:首先得在新的主机环境中安装JDK,关闭防火墙.修改selinux.NTP时钟与主机同步.修改hosts.与主机配置ssh免密码登录.保证安装好了perl和py ...

  6. (原)torch7中添加新的层

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6069627.html 参考网址: http://torch.ch/docs/developer-doc ...

  7. gitignore文件中添加新过滤文件,但是此文件已经提交,如何解决?

    gitignore文件中添加新过滤文件,但是此文件已经提交到远程库,如何解决? 第一步,为避免冲突需要先同步下远程仓库 git pull 第二步,在本地项目目录下删除缓存 git rm -r --ca ...

  8. C# 往Datatable中添加新行的步骤

    以一个实例说明 //录入年份绑定 public void YearList(FineUIPro.DropDownList ddlYear) { //年份从15年到当前年//起止年份 ; int yea ...

  9. SqlServer表中添加新字段

    表中添加新字段ALTER TABLE 表名 ADD 字段名 VARCHAR(20) NULL 表中添加自增idalter table lianxi add id int primary key IDE ...

随机推荐

  1. 85.explicit作用

    #include <iostream> using namespace std; class myclass { public: int num; public: explicit myc ...

  2. Aizu - 2555 Everlasting Zero 模拟

    Aizu - 2555 Everlasting Zero 题意:学习技能,每个技能有不同的要求,问能否学习全部特殊技能 思路:枚举每两个技能,得到他们的先后学习关系,如果两个都不能先学的话就是No了, ...

  3. css3 实现动画效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. C/C++(C++返回对象与应用区别,类成员的存储)

    返回对象与应用区别: 拷贝构造器发生的时机: 1.构造新对象 A a, A b = a; 2.传参或返回对象 对于普通变量来说,传引用效果不是很明显,对于类对象而言,传对象效果很高. 传引用等价于扩大 ...

  5. python code 1_username registration & login

    This tiny program consists of 2 parts - registration and login. In the part of registration, the key ...

  6. Java Web学习总结(21)——http协议响应状态码大全以及常用状态码

    http协议响应状态码大全以及常用状态码 当我们在浏览网页或是在查看服务器日志时,常会遇到3位数字的状态码,这3位数字是什么意思呢?其实,这3位数字是HTTP状态码,用来表示网页服务器HTTP响应状态 ...

  7. [转]LNMP环境下的Web常见问题排查(精品)

    来源:http://mp.weixin.qq.com/s? __biz=MjM5NzUwNDA5MA==&mid=200596752&idx=1&sn=37ecae802f32 ...

  8. LinkedHashMap<String, Bitmap>(0, 0.75f, true) LinkedHashMap的加载因子和初始容量分配

    今天上午在CSDN的论坛里看到有朋友提的问题如下: /** @param maxSize Maximum sum of the sizes of the Bitmaps in this cache * ...

  9. 怎样通过MSG_WAITALL设置阻塞时间,IO模式精细讲解: MSG_DONTWAIT 、 MSG_WAITALL

    首先给出MSDN上一段设置阻塞超时的代码:(网址为http://social.msdn.microsoft.com/Forums/zh-SG/visualcpluszhchs/thread/3d9da ...

  10. POJ 2437 贪心+priority_queue

    题意: 思路: 贪心 能不覆盖的就不盖 写得很乱 左闭右开的 temp //By SiriusRen #include <queue> #include <cstdio> #i ...