PreferenceFragment加载设置页面
来源:互联网 发布:淘宝远望数码 编辑:程序博客网 时间:2024/04/28 17:39
新的SDK中已经推荐PreferenceFragment代替PreferenceActivity展示设置页面,主要设置参数如下:
XML文件:
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2008 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.--><PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="@string/wifi_tether_setting_title" android:persistent="false"/> <ListPreference android:key="wifi_auto_disable" android:title="@string/wifi_tether_auto_disable_title" android:persistent="false" android:entries="@array/wifi_hotspot_disable_policy_entries" android:entryValues="@array/wifi_hotspot_disable_policy_values"/> <Preference android:key="wifi_ap_ssid_and_security" android:title="@string/wifi_tether_configure_ap_text" android:persistent="false" /> <CheckBoxPreference android:key="suspend_optimizations" android:title="@string/wifi_hotspot_suspend_optimizations" android:summary="@string/wifi_hotspot_suspend_optimizations_summary" android:persistent="false" /> <Preference android:key="wps_connect" android:title="@string/wifi_tether_wps_connect_title" android:summary="@string/wifi_tether_wps_connect_summary" android:persistent="false" /> <Preference android:key="bandwidth_usage" android:title="@string/wifi_ap_bandwidth_title" android:fragment="com.mediatek.wifi.hotspot.BandwidthUsage" android:persistent="false" /> <PreferenceCategory android:key="connected_category" android:title="@string/wifi_ap_connected_title" android:persistent="false"/> <PreferenceCategory android:key="blocked_category" android:title="@string/wifi_ap_blocked_title" android:persistent="false"/></PreferenceScreen>
Activity为:
package com.example.wifihotspot2;import android.preference.PreferenceActivity;import android.app.Activity;import android.content.SharedPreferences; import android.os.Bundle; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.text.AndroidCharacter;import android.view.View; import android.preference.PreferenceFragment; public class SettingsPreferenctScreenActivity extends Activity { SharedPreferences prefs; /* (non-Javadoc) * @see android.preference.PreferenceActivity#onCreate(android.os.Bundle) */@Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);getFragmentManager().beginTransaction().replace(android.R.id.content, new PrefsFragement()).commit();} public static class PrefsFragement extends PreferenceFragment{/* (non-Javadoc) * @see android.preference.PreferenceFragment#onCreate(android.os.Bundle) */@Overridepublic void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);addPreferencesFromResource(R.xml.tether_wifi_prefs);} }}
0 0
- PreferenceFragment加载设置页面
- Android设置Settings:PreferenceFragment【4】
- Android设置Settings:PreferenceFragment【4】
- Android PreferenceFragment实现设置界面
- 使用PreferenceFragment实现设置模块
- 设置APP加载页面
- PreferenceFragment
- PreferenceFragment
- Android学习【9】PreferenceFragment偏好设置(一)
- Android学习【10】PreferenceFragment偏好设置(二)
- Android设置Settings:PreferenceFragment(2)
- Android 设置PreferenceFragment 的背景颜色
- PreferenceActivity和PreferenceFragment实现设置界面
- Android中设置界面PreferenceFragment的用法
- fragment+viewpage设置不预加载页面
- android 重新加载网络页面设置
- viewpager设置预加载页面数目
- Android笔记——PreferenceActivity结合PreferenceFragment创建设置界面
- (素材源码)猫猫学IOS(十九)UI之QQ好友列表
- 毕业设计 4_14 多任务
- css heml js 遮罩
- Hello World,Hello CSDN
- 签名密钥和加密密钥区别
- PreferenceFragment加载设置页面
- Velocity的基本用法
- 删除僵尸实例的shell脚本
- html里面增删查改元素
- 遥感三种图像存储方式
- 仍然是自动布局,没时间写原创,首先转载一些比较好的例子(没时间其实是借口)
- 各种回归算法
- sql having 小记
- Chrome无法打开文件的错误 [Not allowed to load local resource: file://XXXX]