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>
總結
以上是生活随笔為你收集整理的PreferenceScreen1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 机器学习数据集
- 下一篇: 使用 Android Preferenc