转载

package com.example.app;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.Menu;

import android.view.MenuItem;

public class MainActivity extends PreferenceActivity {

@Override
    public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //加载第一个布局
            addPreferencesFromResource(R.layout.activity_main);          
    }

}

配置文件

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    android:key="using_categories_in_root_screen"
    android:summary="Using Preference Categories"
    android:title="Categories" >

<PreferenceCategory
        android:key="meats_screen"
        android:summary="Preferences related to Meats"
        android:title="肉类" >
        <CheckBoxPreference
            android:key="fish_selection_pref"
            android:summary="小心扎嗓子"
            android:title="鱼" />
        <CheckBoxPreference
            android:key="lamb_selection_pref"
            android:summary="小肥羊吃多了不好"
            android:title="羊肉" />
        <CheckBoxPreference
            android:key="chicken_selection_pref"
            android:summary="营养价值不够高"
            android:title="鸡肉" />
    </PreferenceCategory>
    <PreferenceCategory
        android:key="vegi_screen"
        android:summary="Preferences related to vegetable"
        android:title="蔬菜类" >
        <CheckBoxPreference
            android:key="tomato_selection_pref"
            android:summary="西红柿可以炒鸡蛋⊙﹏⊙"
            android:title="西红柿" />
        <CheckBoxPreference
            android:key="xilanhua_selection_pref"
            android:summary="营养价值很丰富"
            android:title="西兰花" />
    </PreferenceCategory>
</PreferenceScreen>

PreferenceScreen1相关推荐

  1. Preference的使用(2) --- PreferenceCategory PreferenceScreen

    上一节有讲到Preference的基本使用跟API的介绍 ,没有看的话请先阅读 Preference的使用(1) 现在介绍其子类PreferenceCategory  跟 PreferenceScre ...

最新文章

  1. 基于人工神经网络的不规则小天体引力场建模
  2. 谋定数字农业生态系统 万亿市场对话中国农民丰收节交易会
  3. 串口光猫应用领域及技术参数详解
  4. php 堵塞 消息队列,PHP的并发处理
  5. TimeSpan 用法 求离最近发表时间的函数
  6. ngnix学习(二)ngnix常用命令
  7. php伪随机数 ctf,[GWCTF 2019]枯燥的抽奖
  8. codeforces 340E Iahub and Permutations(错排or容斥)
  9. 视频显示器与服务器之间使用什么线连接,显示器连接线有哪些?四种主流连线科普。...
  10. 移动端产品比较分析:APP、小程序、H5
  11. 整人代码好玩到没朋友
  12. 视频一键识别生成字幕
  13. 张轩睿和Selina要复合?任家萱的粉丝们会同意吗
  14. HTTP 错误 404.3 – Not Found 由于扩展配置问题而无法提供您请求的页面。如果该页面是脚本,请添加处理程序。如果应下载文件,请添加 MIME 映射。
  15. Telsa显卡时间轴
  16. 腾讯云服务器计费模式包年包月/按量计费/竞价实例选择困难户
  17. 非极大值抑制(non-maximum suppression)的理解
  18. 未来科学技十幻想画计算机,未来世界科幻画图片 你憧憬过这样的未来吗
  19. 关于“产品驱动”和“技术驱动”
  20. linux系统有哪些版本 linux系统哪个版本好用

热门文章

  1. 3DMAX 的重要知识和插件介绍
  2. nodejs 实现 磁力链接资源搜索 BT磁力链接爬虫
  3. UVC1.5协议 2
  4. 如何固定电脑桌面便签 win7便签怎么设置?
  5. 电脑文件分区壁纸--超级马里奥、樱桃小丸子主题
  6. Nginx(1)— Nginx工作原理
  7. 36款免费可商用字体 附字体分享链接
  8. EXCEL闪退的处理方法
  9. Docker-删除untagged docker images
  10. AMESim2020MATLAB2020b联合仿真设置