本文整理匯總了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);
}
}
示例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);
}
}
示例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;
}