本文整理汇总了Java中android.preference.Preference.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.setEnabled方法的具体用法?Java Preference.setEnabled怎么用?Java Preference.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.Preference
的用法示例。
在下文中一共展示了Preference.setEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResume
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
refreshNotificationListeners();
lookupRingtoneNames();
updateNotificationPreferenceState();
mSettingsObserver.register(true);
mReceiver.register(true);
updateRingPreference();
updateEffectsSuppressor();
for (VolumeSeekBarPreference volumePref : mVolumePrefs) {
volumePref.onActivityResume();
}
if (mIncreasingRingVolume != null) {
mIncreasingRingVolume.onActivityResume();
}
boolean isRestricted = mUserManager.hasUserRestriction(UserManager.DISALLOW_ADJUST_VOLUME);
for (String key : RESTRICTED_KEYS) {
Preference pref = findPreference(key);
if (pref != null) {
pref.setEnabled(!isRestricted);
}
}
}
示例2: disableOnlyFullAppPrefs
import android.preference.Preference; //导入方法依赖的package包/类
private void disableOnlyFullAppPrefs() {
String fullOnly = " FULL ONLY ";
int color = Utils.adjustAlpha(CurrentTheme.getColorAccent(getActivity()), 100);
for (String name : AppPrefs.ONLY_FULL_APP_PREFS) {
Preference preference = findPreference(name);
if (preference != null) {
preference.setEnabled(false);
CharSequence summary = TextUtils.isEmpty(preference.getTitle()) ? "" : preference.getTitle();
summary = fullOnly + " " + summary;
Spannable spannable = SpannableStringBuilder.valueOf(summary);
BackgroundColorSpan span = new BackgroundColorSpan(color);
ForegroundColorSpan span1 = new ForegroundColorSpan(Color.WHITE);
spannable.setSpan(span, 0, fullOnly.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(span1, 0, fullOnly.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
preference.setTitle(spannable);
}
}
}
示例3: UpgradePro
import android.preference.Preference; //导入方法依赖的package包/类
private void UpgradePro() {
Preference darkKey = findPreference("DARK_THEME_KEY");
darkKey.setEnabled(true);
darkKey.setTitle(R.string.DarkThemePro);
Preference SmallFonts = findPreference("EXTRA_SMALL_FONT");
SmallFonts.setEnabled(true);
SmallFonts.setTitle(R.string.ExtraSmallFontTPro);
Preference Rounding = findPreference("ROUNDIND_INFO");
Rounding.setTitle(R.string.EnableRoundingPro);
Rounding.setEnabled(true);
Preference Max = findPreference("MAX_INT");
Max.setEnabled(true);
Max.setTitle(R.string.MaximumTPro);
Preference Min = findPreference("MIN_INT_KEY");
Min.setTitle(R.string.MinimumTPro);
Min.setEnabled(true);
}
示例4: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_settings);
backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
backgroundThread.start();
backgroundHandler = new Handler(backgroundThread.getLooper());
btcPrecisionPreference = findPreference(Configuration.PREFS_KEY_BTC_PRECISION);
btcPrecisionPreference.setOnPreferenceChangeListener(this);
trustedPeerPreference = findPreference(Configuration.PREFS_KEY_TRUSTED_PEER);
((EditTextPreference) trustedPeerPreference).getEditText().setSingleLine();
trustedPeerPreference.setOnPreferenceChangeListener(this);
trustedPeerOnlyPreference = findPreference(Configuration.PREFS_KEY_TRUSTED_PEER_ONLY);
trustedPeerOnlyPreference.setOnPreferenceChangeListener(this);
final Preference dataUsagePreference = findPreference(Configuration.PREFS_KEY_DATA_USAGE);
dataUsagePreference.setEnabled(pm.resolveActivity(dataUsagePreference.getIntent(), 0) != null);
updateTrustedPeer();
}
示例5: onSharedPreferenceChanged
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Preference connectionPref;
SharedPreferences pref = getPreferenceScreen().getSharedPreferences();
switch (key) {
case "pref_key_qr_autofade":
connectionPref = findPreference("pref_key_qr_autofade_time");
connectionPref.setEnabled(sharedPreferences.getBoolean(key, false));
break;
case "pref_key_filter_subst":
findPreference("pref_key_filterby_level").setEnabled(pref.getBoolean("pref_key_filter_subst", false));
findPreference("pref_key_filterby_schedule").setEnabled(pref.getBoolean("pref_key_filter_subst", false));
break;
}
}
示例6: setPreferenceEnabled
import android.preference.Preference; //导入方法依赖的package包/类
static void setPreferenceEnabled(final String prefKey, final boolean enabled,
final PreferenceScreen screen) {
final Preference preference = screen.findPreference(prefKey);
if (preference != null) {
preference.setEnabled(enabled);
}
}
示例7: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
appPreferences = App.getAppPreferences();
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
context = getActivity();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
prefs.registerOnSharedPreferenceChangeListener(this);
prefCustomPath = (EditTextPreference) findPreference(getString(R.string.pref_custom_path));
prefCustomFile = (ListPreference) findPreference(getString(R.string.pref_custom_file));
prefSortMethod = (ListPreference) findPreference(getString(R.string.pref_sort_method));
prefTheme = (ListPreference) findPreference(getString(R.string.pref_theme));
// removes settings that wont work on lower versions
Preference prefNavigationColor = findPreference(getString(R.string.pref_navigation_color));
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
prefNavigationColor.setEnabled(false);
}
Preference prefReset = findPreference(getString(R.string.pref_reset));
prefReset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
sharedPreferences.edit().clear().apply();
return true;
}
});
setSortModeSummary();
setThemeSummary();
setCustomPathSummary();
setFilenameSummary();
}
示例8: setVideoBitrateEnable
import android.preference.Preference; //导入方法依赖的package包/类
private void setVideoBitrateEnable(SharedPreferences sharedPreferences) {
Preference bitratePreferenceValue =
settingsFragment.findPreference(keyprefMaxVideoBitrateValue);
String bitrateTypeDefault = getString(R.string.pref_maxvideobitrate_default);
String bitrateType =
sharedPreferences.getString(keyprefMaxVideoBitrateType, bitrateTypeDefault);
if (bitrateType.equals(bitrateTypeDefault)) {
bitratePreferenceValue.setEnabled(false);
} else {
bitratePreferenceValue.setEnabled(true);
}
}
示例9: setAudioBitrateEnable
import android.preference.Preference; //导入方法依赖的package包/类
private void setAudioBitrateEnable(SharedPreferences sharedPreferences) {
Preference bitratePreferenceValue =
settingsFragment.findPreference(keyprefStartAudioBitrateValue);
String bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_default);
String bitrateType =
sharedPreferences.getString(keyprefStartAudioBitrateType, bitrateTypeDefault);
if (bitrateType.equals(bitrateTypeDefault)) {
bitratePreferenceValue.setEnabled(false);
} else {
bitratePreferenceValue.setEnabled(true);
}
}
示例10: setVideoBitrateEnable
import android.preference.Preference; //导入方法依赖的package包/类
private void setVideoBitrateEnable(SharedPreferences sharedPreferences) {
Preference bitratePreferenceValue =
settingsFragment.findPreference(keyprefMaxVideoBitrateValue);
String bitrateTypeDefault = getString(R.string.pref_maxvideobitrate_default);
String bitrateType =
sharedPreferences.getString(keyprefMaxVideoBitrateType, bitrateTypeDefault);
if (bitrateType.equals(bitrateTypeDefault)) {
bitratePreferenceValue.setEnabled(false);
} else {
bitratePreferenceValue.setEnabled(true);
}
}
示例11: setAudioBitrateEnable
import android.preference.Preference; //导入方法依赖的package包/类
private void setAudioBitrateEnable(SharedPreferences sharedPreferences) {
Preference bitratePreferenceValue =
settingsFragment.findPreference(keyprefStartAudioBitrateValue);
String bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_default);
String bitrateType =
sharedPreferences.getString(keyprefStartAudioBitrateType, bitrateTypeDefault);
if (bitrateType.equals(bitrateTypeDefault)) {
bitratePreferenceValue.setEnabled(false);
} else {
bitratePreferenceValue.setEnabled(true);
}
}
示例12: initPreferenceChanges
import android.preference.Preference; //导入方法依赖的package包/类
private void initPreferenceChanges() {
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
Preference qrtime = findPreference("pref_key_notification_time_foodmarks");
qrtime.setEnabled(getPreferenceScreen().getSharedPreferences().getBoolean("pref_key_notification_essensqr", false));
Preference testtime = findPreference("pref_key_notification_time_test");
testtime.setEnabled(getPreferenceScreen().getSharedPreferences().getBoolean("pref_key_notification_test", false));
Preference surveytime = findPreference("pref_key_notification_time_survey");
surveytime.setEnabled(getPreferenceScreen().getSharedPreferences().getBoolean("pref_key_notification_survey", false));
Preference scheduletime = findPreference("pref_key_notification_time_schedule");
scheduletime.setEnabled(getPreferenceScreen().getSharedPreferences().getBoolean("pref_key_notification_schedule", false));
}
示例13: onResume
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
final Preference voiceInputKeyOption = findPreference(Settings.PREF_VOICE_INPUT_KEY);
if (voiceInputKeyOption != null) {
RichInputMethodManager.getInstance().refreshSubtypeCaches();
voiceInputKeyOption.setEnabled(VOICE_IME_ENABLED);
voiceInputKeyOption.setSummary(VOICE_IME_ENABLED
? null : getText(R.string.voice_input_disabled_summary));
}
}
示例14: setOreoSupportSum
import android.preference.Preference; //导入方法依赖的package包/类
private void setOreoSupportSum(Preference... preferences) {
for (Preference preference : preferences) {
preference.setEnabled(false);
preference.setSummary(getString(R.string.android_O_only));
}
}
示例15: createErrorMessage
import android.preference.Preference; //导入方法依赖的package包/类
private static Preference createErrorMessage(final Activity activity, final int messageResource) {
final Preference message = new Preference(activity);
message.setTitle(messageResource);
message.setEnabled(false);
return message;
}