PreferenceScreen1

来源:互联网 发布:淘宝店付费流量是什么 编辑:程序博客网 时间:2024/06/04 18:09

转载

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>

0 0
原创粉丝点击