当前位置: 首页>>代码示例>>Java>>正文


Java SwitchPreference.setDefaultValue方法代码示例

本文整理汇总了Java中android.preference.SwitchPreference.setDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchPreference.setDefaultValue方法的具体用法?Java SwitchPreference.setDefaultValue怎么用?Java SwitchPreference.setDefaultValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.preference.SwitchPreference的用法示例。


在下文中一共展示了SwitchPreference.setDefaultValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.preference.SwitchPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_wireless_socket);
    setHasOptionsMenu(true);

    PreferenceScreen preferenceScreen = this.getPreferenceScreen();

    PreferenceCategory preferenceCategory = new PreferenceCategory(preferenceScreen.getContext());
    preferenceCategory.setTitle("Wireless sockets");
    preferenceScreen.addPreference(preferenceCategory);

    for (int index = 0; index < WirelessSocketService.getInstance().GetDataList().getSize(); index++) {
        WirelessSocket wirelessSocket = WirelessSocketService.getInstance().GetDataList().getValue(index);

        SwitchPreference preference = new SwitchPreference(preferenceScreen.getContext());

        preference.setTitle(wirelessSocket.GetName());
        preference.setKey(wirelessSocket.GetSettingsKey());
        preference.setDefaultValue(false);

        preferenceCategory.addPreference(preference);

        bindPreferenceSummaryToValue(preference);
    }
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:27,代码来源:SettingsActivity.java

示例2: setupDaydreamPreferences

import android.preference.SwitchPreference; //导入方法依赖的package包/类
private void setupDaydreamPreferences() {
    if (!isAdded() ) return;
    enablePreference("autostart",  !Utility.isConfiguredAsDaydream(mContext) );
    Preference pref = findPreference("autostart");
    boolean on = pref.isEnabled();
    String summary = on ? "" : getString(R.string.autostart_message_disabled);
    pref.setSummary(summary);


    PreferenceCategory category = (PreferenceCategory) findPreference("category_behaviour");
    removePreference("force_auto_rotation");
    if (!on) {
        SwitchPreference forceAutoRotation = new SwitchPreference(mContext);
        forceAutoRotation.setKey("force_auto_rotation");
        forceAutoRotation.setTitle(getString(R.string.force_auto_rotation));
        forceAutoRotation.setSummary(getString(R.string.force_auto_rotation_summary));
        forceAutoRotation.setDefaultValue(false);
        category.addPreference(forceAutoRotation);
    }
}
 
开发者ID:firebirdberlin,项目名称:nightdream,代码行数:21,代码来源:PreferencesFragment.java

示例3: getVibrateDuringDndPreference

import android.preference.SwitchPreference; //导入方法依赖的package包/类
private SwitchPreference getVibrateDuringDndPreference() {
    SwitchPreference vibrateDuringDnd = new SwitchPreference(getActivity());
    vibrateDuringDnd.setKey("pref_key_vibrate_during_dnd");
    vibrateDuringDnd
        .setTitle(getActivity().getString
                  (R.string.vibrate_during_dnd_preference_title));
    vibrateDuringDnd
        .setSummary(getActivity().getString
                  (R.string.vibrate_during_dnd_preference_summary));
    vibrateDuringDnd.setDefaultValue(true);
    return vibrateDuringDnd;
}
 
开发者ID:raatmarien,项目名称:chibe,代码行数:13,代码来源:ChibeFragment.java


注:本文中的android.preference.SwitchPreference.setDefaultValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。