當前位置: 首頁>>代碼示例>>Java>>正文


Java Preference.setEnabled方法代碼示例

本文整理匯總了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);
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:20,代碼來源:NotifPreferenceFragment.java

示例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);
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:18,代碼來源:NotifPreferenceFragment.java

示例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);
}
 
開發者ID:garretyoder,項目名稱:Cluttr,代碼行數:30,代碼來源:SettingsActivity.java

示例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);
    }
}
 
開發者ID:Maxr1998,項目名稱:home-assistant-Android,代碼行數:30,代碼來源:SettingsActivity.java


注:本文中的android.support.v7.preference.Preference.setEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。