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


Java PreferenceGroup.removePreference方法代码示例

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


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

示例1: onSaveCustomInputStyle

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void onSaveCustomInputStyle(final CustomInputStylePreference stylePref) {
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (!stylePref.hasBeenModified()) {
        return;
    }
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        return;
    }

    // Saved subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    stylePref.revert();
    group.addPreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:19,代码来源:CustomInputStyleSettingsFragment.java

示例2: onAddCustomInputStyle

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void onAddCustomInputStyle(final CustomInputStylePreference stylePref) {
    mIsAddingNewSubtype = false;
    final InputMethodSubtype subtype = stylePref.getSubtype();
    if (findDuplicatedSubtype(subtype) == null) {
        mRichImm.setAdditionalInputMethodSubtypes(getSubtypes());
        mSubtypePreferenceKeyForSubtypeEnabler = stylePref.getKey();
        mSubtypeEnablerNotificationDialog = createDialog();
        mSubtypeEnablerNotificationDialog.show();
        return;
    }

    // Newly added subtype is duplicated.
    final PreferenceGroup group = getPreferenceScreen();
    group.removePreference(stylePref);
    showSubtypeAlreadyExistsToast(subtype);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:18,代码来源:CustomInputStyleSettingsFragment.java

示例3: restoreDefaults

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
 * Restores the default preferences, which are contained by a specific preference group.
 *
 * @param preferenceGroup
 *         The preference group, whose preferences should be restored, as an instance of the
 *         class {@link PreferenceGroup}. The preference group may not be null
 * @param sharedPreferences
 *         The shared preferences, which should be used to restore the preferences, as an
 *         instance of the type {@link SharedPreferences}. The shared preferences may not be
 *         null
 */
private void restoreDefaults(@NonNull final PreferenceGroup preferenceGroup,
                             @NonNull final SharedPreferences sharedPreferences) {
    for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) {
        Preference preference = preferenceGroup.getPreference(i);

        if (preference instanceof PreferenceGroup) {
            restoreDefaults((PreferenceGroup) preference, sharedPreferences);
        } else if (preference.getKey() != null && !preference.getKey().isEmpty()) {
            Object oldValue = sharedPreferences.getAll().get(preference.getKey());

            if (notifyOnRestoreDefaultValueRequested(preference, oldValue)) {
                sharedPreferences.edit().remove(preference.getKey()).apply();
                preferenceGroup.removePreference(preference);
                preferenceGroup.addPreference(preference);
                Object newValue = sharedPreferences.getAll().get(preference.getKey());
                notifyOnRestoredDefaultValue(preference, oldValue, newValue);
            } else {
                preferenceGroup.removePreference(preference);
                preferenceGroup.addPreference(preference);
            }

        }
    }
}
 
开发者ID:michael-rapp,项目名称:AndroidPreferenceActivity,代码行数:36,代码来源:PreferenceFragment.java

示例4: hideAdvancedPreferences

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void hideAdvancedPreferences(PreferenceGroup group) {
    if(mAdvancedSettings.showAll()) {
        return;
    }

    int c = 0;
    while(c < group.getPreferenceCount()) {
        Preference pref = group.getPreference(c);
        if(!mAdvancedSettings.isVisible(group, pref)) {
            group.removePreference(pref);
        } else {
            if(pref instanceof PreferenceGroup) {
                hideAdvancedPreferences((PreferenceGroup)pref);
            }
            c++;
        }
    }
}
 
开发者ID:hmrs-cr,项目名称:android-nmea-logger,代码行数:19,代码来源:SettingsActivity.java

示例5: recursiveDelete

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
 * Recursively traverses the tree from the given group as the route and
 * tries to delete the preference. Traversal stops once the preference
 * was found and removed.
 */
private boolean recursiveDelete(PreferenceGroup group, Preference preference) {
    if (group == null) {
        Log.d(TAG, "attempting to delete from null preference group");
        return false;
    }
    if (preference == null) {
        Log.d(TAG, "attempting to delete null preference");
        return false;
    }
    if (group.removePreference(preference)) {
        // Removal was successful.
        return true;
    }

    for (int i = 0; i < group.getPreferenceCount(); ++i) {
        Preference pref = group.getPreference(i);
        if (pref instanceof PreferenceGroup) {
            if (recursiveDelete((PreferenceGroup) pref, preference)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:30,代码来源:CameraSettingsActivity.java

示例6: assignPlayStoreIntentToPreference

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void assignPlayStoreIntentToPreference(int preferenceId, String url) {
    final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
            R.string.pref_category_miscellaneous_key);
    final Preference pref = findPreferenceByResId(preferenceId);
    if (pref == null) {
        return;
    }

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    if (!canHandleIntent(intent)) {
        category.removePreference(pref);
        return;
    }

    pref.setIntent(intent);
}
 
开发者ID:google,项目名称:talkback,代码行数:17,代码来源:TalkBackPreferencesActivity.java

示例7: assignTtsSettingsIntent

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
 * Assigns the intent to open text-to-speech settings.
 */
private void assignTtsSettingsIntent() {
    PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
        R.string.pref_category_when_to_speak_key);
    Preference ttsSettingsPreference =
            findPreferenceByResId(R.string.pref_tts_settings_key);

    if (category == null || ttsSettingsPreference == null) {
        return;
    }

    Intent ttsSettingsIntent = new Intent(TalkBackService.INTENT_TTS_SETTINGS);
    ttsSettingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (!canHandleIntent(ttsSettingsIntent)) {
        // Need to remove preference item if no TTS Settings intent filter in settings app.
        category.removePreference(ttsSettingsPreference);
    }

    ttsSettingsPreference.setIntent(ttsSettingsIntent);
}
 
开发者ID:google,项目名称:talkback,代码行数:23,代码来源:TalkBackPreferencesActivity.java

示例8: assignLabelManagerIntent

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
 * Assigns the appropriate intent to the label manager preference.
 */
private void assignLabelManagerIntent() {
    final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
            R.string.pref_category_touch_exploration_key);
    final Preference prefManageLabels = findPreferenceByResId(
            R.string.pref_manage_labels_key);

    if ((category == null) || (prefManageLabels == null)) {
        return;
    }

    if (Build.VERSION.SDK_INT < LabelManagerSummaryActivity.MIN_API_LEVEL) {
        category.removePreference(prefManageLabels);
        return;
    }

    Activity activity = getActivity();
    if (activity != null) {
        final Intent labelManagerIntent = new Intent(
                activity, LabelManagerSummaryActivity.class);
        labelManagerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        labelManagerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        prefManageLabels.setIntent(labelManagerIntent);
    }
}
 
开发者ID:google,项目名称:talkback,代码行数:28,代码来源:TalkBackPreferencesActivity.java

示例9: assignKeyboardShortcutIntent

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
 * Assigns the appropriate intent to the keyboard shortcut preference.
 */
private void assignKeyboardShortcutIntent() {
    final PreferenceGroup category =
            (PreferenceGroup) findPreferenceByResId(
                    R.string.pref_category_miscellaneous_key);
    final Preference keyboardShortcutPref = findPreferenceByResId(
            R.string.pref_category_manage_keyboard_shortcut_key);

    if ((category == null) || (keyboardShortcutPref == null)) {
        return;
    }

    if (Build.VERSION.SDK_INT < KeyComboManager.MIN_API_LEVEL) {
        category.removePreference(keyboardShortcutPref);
        return;
    }

    Activity activity = getActivity();
    if (activity != null) {
        final Intent labelManagerIntent = new Intent(activity,
                TalkBackKeyboardShortcutPreferencesActivity.class);
        labelManagerIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        labelManagerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        keyboardShortcutPref.setIntent(labelManagerIntent);
    }
}
 
开发者ID:google,项目名称:talkback,代码行数:29,代码来源:TalkBackPreferencesActivity.java

示例10: updateTalkBackShortcutStatus

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void updateTalkBackShortcutStatus() {
    final TwoStatePreference preference = (TwoStatePreference) findPreferenceByResId(
            R.string.pref_two_volume_long_press_key);
    if (preference == null) {
        return;
    }
    if (Build.VERSION.SDK_INT >= ProcessorVolumeStream.MIN_API_LEVEL) {
        preference.setEnabled(
                TalkBackService.getInstance() != null || preference.isChecked());
    } else {
        final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
                R.string.pref_category_miscellaneous_key);
        if (category == null) {
            return;
        }
        category.removePreference(preference);
    }

}
 
开发者ID:google,项目名称:talkback,代码行数:20,代码来源:TalkBackPreferencesActivity.java

示例11: checkVibrationSupport

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
 * Ensure that the vibration setting does not appear on devices without a
 * vibrator.
 */
private void checkVibrationSupport() {
    Activity activity = getActivity();
    if (activity == null) {
        return;
    }

    final Vibrator vibrator = (Vibrator) activity.getSystemService(VIBRATOR_SERVICE);

    if (vibrator != null && vibrator.hasVibrator()) {
        return;
    }

    final PreferenceGroup category =
            (PreferenceGroup) findPreferenceByResId(R.string.pref_category_feedback_key);
    final TwoStatePreference prefVibration =
            (TwoStatePreference) findPreferenceByResId(R.string.pref_vibration_key);

    if (prefVibration != null) {
        prefVibration.setChecked(false);
        category.removePreference(prefVibration);
    }
}
 
开发者ID:google,项目名称:talkback,代码行数:27,代码来源:TalkBackPreferencesActivity.java

示例12: checkProximitySupport

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
 * Ensure that the proximity sensor setting does not appear on devices
 * without a proximity sensor.
 */
private void checkProximitySupport() {
    Activity activity = getActivity();
    if (activity == null) {
        return;
    }

    final SensorManager manager = (SensorManager) activity.getSystemService(SENSOR_SERVICE);
    final Sensor proximity = manager.getDefaultSensor(Sensor.TYPE_PROXIMITY);

    if (proximity != null) {
        return;
    }

    final PreferenceGroup category = (PreferenceGroup) findPreferenceByResId(
            R.string.pref_category_when_to_speak_key);
    final TwoStatePreference prefProximity =
            (TwoStatePreference) findPreferenceByResId(R.string.pref_proximity_key);

    if (prefProximity != null) {
        prefProximity.setChecked(false);
        category.removePreference(prefProximity);
    }
}
 
开发者ID:google,项目名称:talkback,代码行数:28,代码来源:TalkBackPreferencesActivity.java

示例13: removeCookie

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private boolean removeCookie(String cookie, boolean preferenceOnly) {
	if (!preferenceOnly) {
		configuration.storeCookie(cookie, null, null);
		configuration.commit();
	}
	CookiePreference preference = (CookiePreference) findPreference(cookie);
	if (preference != null) {
		PreferenceGroup preferenceGroup = getParentGroup(preference);
		preferenceGroup.removePreference(preference);
		cookies.remove(cookie);
		if (preferenceGroup.getPreferenceCount() == 0) {
			getActivity().finish();
			return true;
		}
	}
	return false;
}
 
开发者ID:Mishiranu,项目名称:Dashchan,代码行数:18,代码来源:CookiesFragment.java

示例14: onCreate

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.battery_light_settings);

    PreferenceScreen prefSet = getPreferenceScreen();

    PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference("general_section");

    mLightEnabledPref = (CMSystemSettingSwitchPreference) prefSet.findPreference(LIGHT_ENABLED_PREF);
    mPulseEnabledPref = (CMSystemSettingSwitchPreference) prefSet.findPreference(PULSE_ENABLED_PREF);

    if (!getResources().getBoolean(com.android.internal.R.bool.config_ledCanPulse) ||
            getResources().getBoolean(org.cyanogenmod.platform.internal.R.bool.config_useSegmentedBatteryLed)) {
        mGeneralPrefs.removePreference(mPulseEnabledPref);
    }

    // Does the Device support changing battery LED colors?
    if (getResources().getBoolean(com.android.internal.R.bool.config_multiColorBatteryLed)) {
        setHasOptionsMenu(true);

        // Low, Medium and full color preferences
        mLowColorPref = (ApplicationLightPreference) prefSet.findPreference(LOW_COLOR_PREF);
        mLowColorPref.setOnPreferenceChangeListener(this);

        mMediumColorPref = (ApplicationLightPreference) prefSet.findPreference(MEDIUM_COLOR_PREF);
        mMediumColorPref.setOnPreferenceChangeListener(this);

        mFullColorPref = (ApplicationLightPreference) prefSet.findPreference(FULL_COLOR_PREF);
        mFullColorPref.setOnPreferenceChangeListener(this);
    } else {
        prefSet.removePreference(prefSet.findPreference("colors_list"));
        resetColors();
    }
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:36,代码来源:BatteryLightSettings.java

示例15: removeAdvancePreference

import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void removeAdvancePreference(Preference preference) {
  // these null checks are to fix a crash due to an NPE on 4.4.4
  if (preference != null) {
    PreferenceGroup group =
        (PreferenceGroup) findPreference(Constants.PREF_QURAN_SETTINGS);
    if (group != null) {
      group.removePreference(preference);
    }
  }
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:11,代码来源:QuranAdvancedSettingsFragment.java


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