本文整理汇总了Java中android.support.v7.preference.Preference.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.setEnabled方法的具体用法?Java Preference.setEnabled怎么用?Java Preference.setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.Preference
的用法示例。
在下文中一共展示了Preference.setEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateLinesPreferenceSummary
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
private void updateLinesPreferenceSummary(MultiSelectListPreference preference, Set<String> values) {
List<String> sortedValues = new ArrayList<String>(values);
Collections.sort(sortedValues);
if (!values.isEmpty()) {
CharSequence summary = getSelectedEntries(sortedValues, preference).toString();
summary = summary.subSequence(1, summary.length() - 1);
preference.setSummary(String.format(getString(R.string.frag_notif_summary_lines), summary));
} else {
preference.setSummary(getString(R.string.frag_notif_summary_no_lines));
}
Preference notifsDistServiceResumed = findPreference("pref_notifs_service_resumed");
Preference notifsDistRingtone = findPreference("pref_notifs_ringtone");
Preference notifsDistVibrate = findPreference("pref_notifs_vibrate");
notifsDistServiceResumed.setEnabled(values.size() != 0);
notifsDistRingtone.setEnabled(values.size() != 0);
notifsDistVibrate.setEnabled(values.size() != 0);
}
示例2: updateSourcesPreferenceSummary
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
private void updateSourcesPreferenceSummary(MultiSelectListPreference preference, Set<String> values) {
List<String> sortedValues = new ArrayList<String>(values);
Collections.sort(sortedValues);
if (!values.isEmpty()) {
CharSequence summary = getSelectedEntries(sortedValues, preference).toString();
summary = summary.subSequence(1, summary.length() - 1);
preference.setSummary(String.format(getString(R.string.frag_notif_summary_sources), summary));
} else {
preference.setSummary(getString(R.string.frag_notif_summary_no_sources));
}
Preference notifsAnnRingtone = findPreference("pref_notifs_announcement_ringtone");
Preference notifsAnnVibrate = findPreference("pref_notifs_announcement_vibrate");
notifsAnnRingtone.setEnabled(values.size() != 0);
notifsAnnVibrate.setEnabled(values.size() != 0);
}
示例3: invalidateSettings
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
public void invalidateSettings() {
SwitchPreference dark = (SwitchPreference) findPreference("dark_theme");
ExcludeFolderPreference exclude = (ExcludeFolderPreference) findPreference("excluded_folders_listener_key");
ColorPickerPreference primary = (ColorPickerPreference) findPreference("primary");
ColorPickerPreference accent = (ColorPickerPreference) findPreference("accent");
Preference security = findPreference("security_placeholder");
Preference animations = findPreference("animations");
Preference staggered = findPreference("staggered");
Preference cache = findPreference("clear_cache_placeholder");
Preference sdcard = findPreference("externalsd_placeholder");
Preference removesd = findPreference("removesd_placeholder");
sdcard.setSummary(ExtSdHelper.getSdPath()==null ? getContext().getResources().getString(R.string.no_sd) : ExtSdHelper.getSdPath().substring(ExtSdHelper.getSdPath().lastIndexOf("/")+1));
if (Build.VERSION.SDK_INT < 21) {
sdcard.setEnabled(false);
}
removesd.setOnPreferenceClickListener(this);
sdcard.setOnPreferenceClickListener(this);
security.setOnPreferenceClickListener(this);
exclude.setOnPreferenceClickListener(this);
cache.setOnPreferenceClickListener(this);
staggered.setOnPreferenceChangeListener(this);
animations.setOnPreferenceChangeListener(this);
dark.setOnPreferenceChangeListener(this);
primary.setOnPreferenceChangeListener(this);
accent.setOnPreferenceChangeListener(this);
}
示例4: updatePreferenceSummaries
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
private void updatePreferenceSummaries() {
Preference enableLocationTracking = findPreference(Common.PREF_ENABLE_LOCATION_TRACKING);
enableLocationTracking.setOnPreferenceChangeListener((preference, newValue) -> {
if (newValue == Boolean.TRUE && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 0);
return false;
}
updateLocationTracker();
return true;
});
Preference deviceName = findPreference(Common.PREF_LOCATION_DEVICE_NAME);
deviceName.setSummary(getResources().getString(R.string.preference_location_device_name_summary, prefs.getString(deviceName.getKey(), "nothing")));
deviceName.setOnPreferenceChangeListener((preference, newValue) -> {
preference.setSummary(getResources().getString(R.string.preference_location_device_name_summary, newValue));
updateLocationTracker();
return true;
});
Preference updateInterval = findPreference(Common.PREF_LOCATION_UPDATE_INTERVAL);
int selectedIndex = Arrays.binarySearch(getResources().getIntArray(R.array.location_update_interval_values), prefs.getInt(updateInterval.getKey(), 10));
updateInterval.setSummary(getResources().getStringArray(R.array.location_update_interval_summaries)[selectedIndex]);
Preference resetIgnoredSSLMismatches = findPreference(Common.PREF_RESET_HOST_MISMATCHES);
if (prefs.getStringSet(Common.PREF_ALLOWED_HOST_MISMATCHES_KEY, null) == null) {
resetIgnoredSSLMismatches.setSummary(R.string.preference_reset_host_mismatches_summary_empty);
resetIgnoredSSLMismatches.setEnabled(false);
}
}