标签:android style blog http java os strong 文件
通常app都会有一个设置界面,如下:
package com.example.preferenceactivitydemo1; import android.os.Bundle; import android.preference.PreferenceActivity; public class MainActivity extends PreferenceActivity { @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.main_preference); } }
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:title="标题" > <PreferenceCategory android:summary="分组1" android:title="分组1标题" > <ListPreference android:defaultValue="@string/defaultvalues" android:dialogTitle="对话框标题" android:entries="@array/entries" android:entryValues="@array/entriesvalue" android:key="myListPreference" android:summary="标题说明" android:title="小标题" /> <CheckBoxPreference android:key="doubi" android:summaryOff="逗比模式关闭" android:summaryOn="逗比模式开启" android:title="逗比模式" > </CheckBoxPreference> </PreferenceCategory> <PreferenceCategory android:summary="分组2" android:title="分组2标题" > <SwitchPreference android:key="fly" android:summaryOff="已关闭飞行模式" android:summaryOn="已开启飞行模式" android:switchTextOff="关闭" android:switchTextOn="开启" android:title="飞行模式" > </SwitchPreference> <EditTextPreference android:defaultValue="zhangsan" android:dialogTitle="编辑姓名" android:key="name" android:summary="编辑您的姓名" android:title="编辑" > </EditTextPreference> </PreferenceCategory> </PreferenceScreen>
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">PreferenceActivityDemo1</string> <string name="action_settings">Settings</string> <string name="hello_world">Hello world!</string> <string-array name="entries"> <item>小苹果</item> <item>小香蕉</item> <item>小西瓜</item> </string-array> <string-array name="entriesvalue"> <item>apple</item> <item>banana</item> <item>watermelon</item> </string-array> <string name="defaultvalues">apple</string> </resources>
【安卓笔记】快速开发设置界面-----PreferenceActivity,布布扣,bubuko.com
【安卓笔记】快速开发设置界面-----PreferenceActivity
标签:android style blog http java os strong 文件
原文地址:http://blog.csdn.net/chdjj/article/details/38130345