本文整理匯總了Java中android.preference.Preference.setDefaultValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Preference.setDefaultValue方法的具體用法?Java Preference.setDefaultValue怎麽用?Java Preference.setDefaultValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.preference.Preference
的用法示例。
在下文中一共展示了Preference.setDefaultValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPreferenceChange
import android.preference.Preference; //導入方法依賴的package包/類
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = newValue.toString();
if (isNewAccount) {
//TODO
//builder.setTransport(transport);
} else {
mPrefs.setAccountTransport(n, key);
preference.setSummary(mPrefs.getAccountTransportString(n));
preference.setDefaultValue(mPrefs.getAccountTransportKey(n));
if (mProxyPreference != null) {
String newProxy = mPrefs.getAccountProxy(n);
mProxyPreference.setSummary(newProxy);
mProxyPreference.setText(newProxy);
}
}
return true;
}
示例2: onCreate
import android.preference.Preference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getPreferenceManager().setSharedPreferencesName(LauncherFiles.SHARED_PREFERENCES_KEY);
addPreferencesFromResource(R.xml.launcher_preferences);
// Setup allow rotation preference
Preference rotationPref = findPreference(Utilities.ALLOW_ROTATION_PREFERENCE_KEY);
if (getResources().getBoolean(R.bool.allow_rotation)) {
// Launcher supports rotation by default. No need to show this setting.
getPreferenceScreen().removePreference(rotationPref);
} else {
ContentResolver resolver = getActivity().getContentResolver();
mRotationLockObserver = new SystemDisplayRotationLockObserver(rotationPref, resolver);
// Register a content observer to listen for system setting changes while
// this UI is active.
resolver.registerContentObserver(
Settings.System.getUriFor(System.ACCELEROMETER_ROTATION),
false, mRotationLockObserver);
// Initialize the UI once
mRotationLockObserver.onChange(true);
rotationPref.setDefaultValue(Utilities.getAllowRotationDefaultValue(getActivity()));
}
}
示例3: onPreferenceChange
import android.preference.Preference; //導入方法依賴的package包/類
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
String stringValue = value.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
} else if (preference instanceof SwitchPreference) {
// For a boolean value, set the default value "true"
preference.setDefaultValue((stringValue.contains("t")));
} else {
// For all other preferences, set the summary to the value's
// simple string representation.
preference.setSummary(stringValue);
}
return true;
}