PreferenceScreen1

转载

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值