当前位置: 首页>>代码示例>>Java>>正文


Java SwitchPreferenceCompat.setOnPreferenceChangeListener方法代码示例

本文整理汇总了Java中android.support.v7.preference.SwitchPreferenceCompat.setOnPreferenceChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java SwitchPreferenceCompat.setOnPreferenceChangeListener方法的具体用法?Java SwitchPreferenceCompat.setOnPreferenceChangeListener怎么用?Java SwitchPreferenceCompat.setOnPreferenceChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.preference.SwitchPreferenceCompat的用法示例。


在下文中一共展示了SwitchPreferenceCompat.setOnPreferenceChangeListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onViewCreated

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
    super.onViewCreated(view, savedInstanceState);
    app = (App) getContext().getApplicationContext();
    view.setBackgroundColor(Color.parseColor("#FFFFFF"));
    SwitchPreferenceCompat preference = (SwitchPreferenceCompat)findPreference("enableNotifications");
    preference.setOnPreferenceChangeListener(onSetAlarm);
    ListPreference delay = (ListPreference)findPreference("delayNotifications");
    delay.setOnPreferenceChangeListener(onDelayChange);
    CheckBoxPreference display = (CheckBoxPreference)findPreference("displaySilNotification");
    display.setOnPreferenceChangeListener(onDisplayChange);
    if (app.getPublicPreferenceB(Common.GLOBAL_SETTING_ISNOTIFON)) {
        preference.setChecked(true);
        delay.setEnabled(true);
        delay.setValueIndex(getIdByTime(app.account.getNotificationTime()));
        display.setEnabled(true);
        display.setChecked(app.getPublicPreferenceB(Common.GLOBAL_SETTING_NOTIFICATIONDISPLAY));
    } else {
        preference.setChecked(false);
        delay.setEnabled(false);
        display.setEnabled(false);
        display.setChecked(false);
    }
}
 
开发者ID:Onelio,项目名称:ConnectU,代码行数:26,代码来源:NotificationsFragment.java

示例2: onCreatePreferencesFix

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreatePreferencesFix(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.app_preferences);
    PreferenceScreen mainPreferenceScreen = (PreferenceScreen) findPreference("mainPreferenceScreen");
    pushPreferenceCat = findPreference("pushCat");
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        Preference downloadNotificationCat = findPreference("downloadNotificationCat");
        mainPreferenceScreen.removePreference(downloadNotificationCat);

    }
    crashlyticsAlwaysSendPreference = (SwitchPreferenceCompat) findPreference(getString(R.string.pref_key_crashlytics_always_send));
    crashlyticsAlwaysSendPreference.setChecked(TazSettings.getInstance(getContext())
                                                          .getCrashlyticsAlwaysSend());
    crashlyticsAlwaysSendPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            TazSettings.getInstance(preference.getContext())
                       .setCrashlyticsAlwaysSend((Boolean) newValue);
            return true;
        }
    });
    setPushPrefState(!TextUtils.isEmpty(TazSettings.getInstance(getContext())
                                                   .getFirebaseToken()));
}
 
开发者ID:die-tageszeitung,项目名称:tazapp-android,代码行数:25,代码来源:PreferencesFragment.java

示例3: onCreatePreferences

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    addPreferencesFromResource(R.xml.app_preference);

    suggestions = (SwitchPreferenceCompat) findPreference("suggestions");

    suggestions.setOnPreferenceChangeListener(this);
}
 
开发者ID:hsm59,项目名称:WatchIt,代码行数:9,代码来源:SettingsFragment.java

示例4: accountChanged

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void accountChanged(Account account) {
    if (account == null) {
        Log.d(TAG, "accountChanged: Null account");
        return;
    }

    setPreferenceDetails(account.getConfig());

    SwitchPreferenceCompat pref = (SwitchPreferenceCompat) findPreference("Account.status");
    if (account.isSip() && pref != null) {
        String status;
        pref.setTitle(account.getAlias());
        if (account.isEnabled()) {
            if (account.isTrying()) {
                status = getString(R.string.account_status_connecting);
            } else if (account.needsMigration()) {
                status = getString(R.string.account_update_needed);
            } else if (account.isInError()) {
                status = getString(R.string.account_status_connection_error);
            } else if (account.isRegistered()) {
                status = getString(R.string.account_status_online);
            } else {
                status = getString(R.string.account_status_unknown);
            }
        } else {
            status = getString(R.string.account_status_offline);
        }
        pref.setSummary(status);
        pref.setChecked(account.isEnabled());

        // An ip2ip account is always ready
        pref.setEnabled(!account.isIP2IP());

        pref.setOnPreferenceChangeListener(changeAccountStatusListener);
    }

    setPreferenceListener(account.getConfig(), changeBasicPreferenceListener);
}
 
开发者ID:savoirfairelinux,项目名称:ring-client-android,代码行数:40,代码来源:GeneralAccountFragment.java

示例5: init

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void init() {
        addPreferencesFromResource(R.xml.settings);

        if (Utils.DONATED) {
            getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
        }

        SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
        if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
            getPreferenceScreen().removePreference(forceEnglish);
        } else {
            forceEnglish.setOnPreferenceChangeListener(this);
        }
/*
        if (Utils.hideStartActivity()) {
            ((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
                    .removePreference(findPreference(KEY_MATERIAL_ICON));
        } else {
            findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
        }
*/
        findPreference(KEY_RESET_DATA).setOnPreferenceClickListener(this);
        findPreference(KEY_UPDATE_NOTIFICATION).setOnPreferenceChangeListener(this);
        findPreference(KEY_CHECK_UPDATE).setOnPreferenceClickListener(this);
        findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
        findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
        findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
        findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
        findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
        findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
        findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);

        if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
            findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
        } else {
            ((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
                    findPreference(KEY_LAST_KMSG));
        }

        findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
        findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
        findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
                || !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
            ((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
                    findPreference(KEY_FINGERPRINT));
        } else {
            mFingerprint = findPreference(KEY_FINGERPRINT);
            mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
        }

        PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
        for (NavigationActivity.NavigationFragment navigationFragment : NavigationActivity.sFragments) {
            Fragment fragment = navigationFragment.mFragment;
            int id = navigationFragment.mId;

            if (fragment != null && fragment.getClass() != SettingsFragment.class) {
                SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
                        new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
                switchPreference.setSummary(getString(id));
                switchPreference.setKey(fragment.getClass().getSimpleName() + "_enabled");
                switchPreference.setChecked(Prefs.getBoolean(fragment.getClass().getSimpleName()
                        + "_enabled", true, getActivity()));
                switchPreference.setOnPreferenceChangeListener(this);
                switchPreference.setPersistent(false);
                sectionsCategory.addPreference(switchPreference);
            }
        }
    }
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:71,代码来源:SettingsFragment.java

示例6: init

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void init() {
    addPreferencesFromResource(R.xml.settings);

    if (Utils.DONATED) {
        getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
    }

    SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
    if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
        getPreferenceScreen().removePreference(forceEnglish);
    } else {
        forceEnglish.setOnPreferenceChangeListener(this);
    }

    if (Utils.hideStartActivity()) {
        ((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
                .removePreference(findPreference(KEY_MATERIAL_ICON));
    } else {
        findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
    }

    findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
    findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
    findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
    findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
    findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
    findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
    findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);

    if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
        findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
    } else {
        ((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
                findPreference(KEY_LAST_KMSG));
    }

    findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
    findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
    findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            || !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
        ((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
                findPreference(KEY_FINGERPRINT));
    } else {
        mFingerprint = findPreference(KEY_FINGERPRINT);
        mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
    }

    PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
    for (NavigationActivity.NavigationFragment navigationFragment : NavigationActivity.sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        if (fragment != null && fragment.getClass() != SettingsFragment.class) {
            SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
                    new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
            switchPreference.setSummary(getString(id));
            switchPreference.setKey(fragment.getClass().getSimpleName() + "_enabled");
            switchPreference.setChecked(Prefs.getBoolean(fragment.getClass().getSimpleName()
                    + "_enabled", true, getActivity()));
            switchPreference.setOnPreferenceChangeListener(this);
            switchPreference.setPersistent(false);
            sectionsCategory.addPreference(switchPreference);
        }
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:68,代码来源:SettingsFragment.java

示例7: setupView

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
private void setupView() {
    publicProfilePreference = (SwitchPreferenceCompat)getPreferenceManager().findPreference(PUBLIC_PROFILE_KEY);
    publicProfilePreference.setOnPreferenceChangeListener(onPublicProfilePreferenceChangeListener);
}
 
开发者ID:rapidpro,项目名称:ureport-android,代码行数:5,代码来源:GeneralSettingsFragment.java

示例8: onCreatePreferences

import android.support.v7.preference.SwitchPreferenceCompat; //导入方法依赖的package包/类
@Override
public void onCreatePreferences(Bundle bundle, String s) {
    addPreferencesFromResource(R.xml.settings);

    if (Utils.DONATED) {
        getPreferenceScreen().removePreference(findPreference(KEY_AD_VIEW));
    }

    SwitchPreferenceCompat forceEnglish = (SwitchPreferenceCompat) findPreference(KEY_FORCE_ENGLISH);
    if (Resources.getSystem().getConfiguration().locale.getLanguage().startsWith("en")) {
        getPreferenceScreen().removePreference(forceEnglish);
    } else {
        forceEnglish.setOnPreferenceChangeListener(this);
    }

    if (Utils.hideStartActivity()) {
        ((PreferenceCategory) findPreference(KEY_USER_INTERFACE))
                .removePreference(findPreference(KEY_MATERIAL_ICON));
    } else {
        findPreference(KEY_MATERIAL_ICON).setOnPreferenceChangeListener(this);
    }

    findPreference(KEY_DARK_THEME).setOnPreferenceChangeListener(this);
    findPreference(KEY_BANNER_RESIZER).setOnPreferenceClickListener(this);
    findPreference(KEY_HIDE_BANNER).setOnPreferenceChangeListener(this);
    findPreference(KEY_ACCENT_COLOR).setOnPreferenceClickListener(this);
    findPreference(KEY_SECTIONS_ICON).setOnPreferenceChangeListener(this);
    findPreference(KEY_APPLY_ON_BOOT_TEST).setOnPreferenceClickListener(this);
    findPreference(KEY_LOGCAT).setOnPreferenceClickListener(this);

    if (Utils.existFile("/proc/last_kmsg") || Utils.existFile("/sys/fs/pstore/console-ramoops")) {
        findPreference(KEY_LAST_KMSG).setOnPreferenceClickListener(this);
    } else {
        ((PreferenceCategory) findPreference(KEY_DEBUGGING_CATEGORY)).removePreference(
                findPreference(KEY_LAST_KMSG));
    }

    findPreference(KEY_DMESG).setOnPreferenceClickListener(this);
    findPreference(KEY_SET_PASSWORD).setOnPreferenceClickListener(this);
    findPreference(KEY_DELETE_PASSWORD).setOnPreferenceClickListener(this);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
            || !FingerprintManagerCompat.from(getActivity()).isHardwareDetected()) {
        ((PreferenceCategory) findPreference(KEY_SECURITY_CATEGORY)).removePreference(
                findPreference(KEY_FINGERPRINT));
    } else {
        mFingerprint = findPreference(KEY_FINGERPRINT);
        mFingerprint.setEnabled(!Prefs.getString("password", "", getActivity()).isEmpty());
    }

    NavigationActivity activity = (NavigationActivity) getActivity();
    PreferenceCategory sectionsCategory = (PreferenceCategory) findPreference(KEY_SECTIONS);
    for (NavigationActivity.NavigationFragment navigationFragment : activity.getFragments()) {
        Class<? extends Fragment> fragmentClass = navigationFragment.mFragmentClass;
        int id = navigationFragment.mId;

        if (fragmentClass != null && fragmentClass != SettingsFragment.class) {
            SwitchPreferenceCompat switchPreference = new SwitchPreferenceCompat(
                    new ContextThemeWrapper(getActivity(), R.style.Preference_SwitchPreferenceCompat_Material));
            switchPreference.setSummary(getString(id));
            switchPreference.setKey(fragmentClass.getSimpleName() + "_enabled");
            switchPreference.setChecked(Prefs.getBoolean(fragmentClass.getSimpleName()
                    + "_enabled", true, getActivity()));
            switchPreference.setOnPreferenceChangeListener(this);
            switchPreference.setPersistent(false);
            sectionsCategory.addPreference(switchPreference);
        }
    }
}
 
开发者ID:Grarak,项目名称:KernelAdiutor,代码行数:70,代码来源:SettingsFragment.java


注:本文中的android.support.v7.preference.SwitchPreferenceCompat.setOnPreferenceChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。