private void setChildrenStarted(PreferenceGroup group, boolean started) {
final int count = group.getPreferenceCount();
for (int i = 0; i < count; i++) {
Preference pref = group.getPreference(i);
if (pref instanceof ApplicationLightPreference) {
ApplicationLightPreference ap = (ApplicationLightPreference) pref;
if (started) {
ap.onStart();
} else {
ap.onStop();
}
} else if (pref instanceof PreferenceGroup) {
setChildrenStarted((PreferenceGroup) pref, started);
}
}
}
java类android.preference.PreferenceGroup的实例源码
NotificationLightSettings.java 文件源码
项目:lineagex86
阅读 21
收藏 0
点赞 0
评论 0
InputLanguageSelection.java 文件源码
项目:keepass2android
阅读 35
收藏 0
点赞 0
评论 0
@Override
protected void onPause() {
super.onPause();
// Save the selected languages
String checkedLanguages = "";
PreferenceGroup parent = getPreferenceScreen();
int count = parent.getPreferenceCount();
for (int i = 0; i < count; i++) {
CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
if (pref.isChecked()) {
Locale locale = mAvailableLanguages.get(i).locale;
checkedLanguages += get5Code(locale) + ",";
}
}
if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor editor = sp.edit();
editor.putString(KP2AKeyboard.PREF_SELECTED_LANGUAGES, checkedLanguages);
SharedPreferencesCompat.apply(editor);
}
SettingsActivity.java 文件源码
项目:order-by-android
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void onResume() {
super.onResume();
//Atribui os valores selecionados
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); ++i) {
Preference preference = getPreferenceScreen().getPreference(i);
if (preference instanceof PreferenceGroup) {
PreferenceGroup preferenceGroup = (PreferenceGroup) preference;
for (int j = 0; j < preferenceGroup.getPreferenceCount(); ++j) {
updatePreference(preferenceGroup.getPreference(j));
}
} else {
updatePreference(preference);
}
}
}
SettingsActivity.java 文件源码
项目:order-by-android
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void onResume() {
super.onResume();
//Atribui os valores selecionados
for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); ++i) {
Preference preference = getPreferenceScreen().getPreference(i);
if (preference instanceof PreferenceGroup) {
PreferenceGroup preferenceGroup = (PreferenceGroup) preference;
for (int j = 0; j < preferenceGroup.getPreferenceCount(); ++j) {
updatePreference(preferenceGroup.getPreference(j));
}
} else {
updatePreference(preference);
}
}
}
SettingsFragment.java 文件源码
项目:IO_Classic_WatchFace
阅读 34
收藏 0
点赞 0
评论 0
/**
* Gets the list of preferences in a PreferenceScreen
*
* @param p preference to add to the list
* @param list of preferences in the PreferenceScreen
* @return a list of all the preferences
*/
private ArrayList<Preference> getPreferenceList(Preference p, ArrayList<Preference> list) {
if (p instanceof PreferenceCategory || p instanceof PreferenceScreen) {
PreferenceGroup prefGroup = (PreferenceGroup) p;
final int prefCount = prefGroup.getPreferenceCount();
for (int i = 0; i < prefCount; i++) {
getPreferenceList(prefGroup.getPreference(i), list);
}
}
if (!(p instanceof PreferenceCategory)) {
list.add(p);
}
return list;
}
CustomInputStyleSettingsFragment.java 文件源码
项目:simple-keyboard
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
CustomInputStyleSettingsFragment.java 文件源码
项目:simple-keyboard
阅读 18
收藏 0
点赞 0
评论 0
@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);
}
TwoStatePreferenceHelper.java 文件源码
项目:simple-keyboard
阅读 26
收藏 0
点赞 0
评论 0
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
final PreferenceGroup group) {
final ArrayList<Preference> preferences = new ArrayList<>();
final int count = group.getPreferenceCount();
for (int index = 0; index < count; index++) {
preferences.add(group.getPreference(index));
}
group.removeAll();
for (int index = 0; index < count; index++) {
final Preference preference = preferences.get(index);
if (preference instanceof CheckBoxPreference) {
addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
} else {
group.addPreference(preference);
if (preference instanceof PreferenceGroup) {
replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
}
}
}
}
AutofillPreferences.java 文件源码
项目:chromium-for-android-56-debug-video
阅读 28
收藏 0
点赞 0
评论 0
private void rebuildProfileList() {
// Add an edit preference for each current Chrome profile.
PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES);
profileCategory.removeAll();
for (AutofillProfile profile : PersonalDataManager.getInstance().getProfilesForSettings()) {
// Add an item on the current page...
Preference pref = new Preference(getActivity());
pref.setTitle(profile.getFullName());
pref.setSummary(profile.getLabel());
if (profile.getIsLocal()) {
pref.setFragment(AutofillProfileEditor.class.getName());
} else {
pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
pref.setFragment(AutofillServerProfilePreferences.class.getName());
}
Bundle args = pref.getExtras();
args.putString(AUTOFILL_GUID, profile.getGUID());
profileCategory.addPreference(pref);
}
}
AutofillPreferences.java 文件源码
项目:chromium-for-android-56-debug-video
阅读 22
收藏 0
点赞 0
评论 0
private void rebuildCreditCardList() {
PreferenceGroup profileCategory =
(PreferenceGroup) findPreference(PREF_AUTOFILL_CREDIT_CARDS);
profileCategory.removeAll();
for (CreditCard card : PersonalDataManager.getInstance().getCreditCardsForSettings()) {
// Add an item on the current page...
Preference pref = new Preference(getActivity());
pref.setTitle(card.getObfuscatedNumber());
pref.setSummary(card.getFormattedExpirationDate(getActivity()));
if (card.getIsLocal()) {
pref.setFragment(AutofillLocalCardEditor.class.getName());
} else {
pref.setFragment(AutofillServerCardEditor.class.getName());
pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
}
Bundle args = pref.getExtras();
args.putString(AUTOFILL_GUID, card.getGUID());
profileCategory.addPreference(pref);
}
}
UserDictionaryList.java 文件源码
项目:AOSP-Kayboard-7.1.2
阅读 25
收藏 0
点赞 0
评论 0
/**
* Creates the entries that allow the user to go into the user dictionary for each locale.
* @param userDictGroup The group to put the settings in.
*/
protected void createUserDictSettings(final PreferenceGroup userDictGroup) {
final Activity activity = getActivity();
userDictGroup.removeAll();
final TreeSet<String> localeSet =
UserDictionaryList.getUserDictionaryLocalesSet(activity);
if (localeSet.size() > 1) {
// Have an "All languages" entry in the languages list if there are two or more active
// languages
localeSet.add("");
}
if (localeSet.isEmpty()) {
userDictGroup.addPreference(createUserDictionaryPreference(null));
} else {
for (String locale : localeSet) {
userDictGroup.addPreference(createUserDictionaryPreference(locale));
}
}
}
CustomInputStyleSettingsFragment.java 文件源码
项目:AOSP-Kayboard-7.1.2
阅读 19
收藏 0
点赞 0
评论 0
@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);
}
CustomInputStyleSettingsFragment.java 文件源码
项目:AOSP-Kayboard-7.1.2
阅读 19
收藏 0
点赞 0
评论 0
@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);
}
TwoStatePreferenceHelper.java 文件源码
项目:AOSP-Kayboard-7.1.2
阅读 24
收藏 0
点赞 0
评论 0
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
final PreferenceGroup group) {
final ArrayList<Preference> preferences = new ArrayList<>();
final int count = group.getPreferenceCount();
for (int index = 0; index < count; index++) {
preferences.add(group.getPreference(index));
}
group.removeAll();
for (int index = 0; index < count; index++) {
final Preference preference = preferences.get(index);
if (preference instanceof CheckBoxPreference) {
addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
} else {
group.addPreference(preference);
if (preference instanceof PreferenceGroup) {
replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
}
}
}
}
TwoStatePreferenceHelper.java 文件源码
项目:AOSP-Kayboard-7.1.2
阅读 19
收藏 0
点赞 0
评论 0
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
final PreferenceGroup group) {
final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
switchPref.setTitle(checkBox.getTitle());
switchPref.setKey(checkBox.getKey());
switchPref.setOrder(checkBox.getOrder());
switchPref.setPersistent(checkBox.isPersistent());
switchPref.setEnabled(checkBox.isEnabled());
switchPref.setChecked(checkBox.isChecked());
switchPref.setSummary(checkBox.getSummary());
switchPref.setSummaryOn(checkBox.getSummaryOn());
switchPref.setSummaryOff(checkBox.getSummaryOff());
switchPref.setSwitchTextOn(EMPTY_TEXT);
switchPref.setSwitchTextOff(EMPTY_TEXT);
group.addPreference(switchPref);
switchPref.setDependency(checkBox.getDependency());
}
DictionarySettingsFragment.java 文件源码
项目:AOSP-Kayboard-7.1.2
阅读 25
收藏 0
点赞 0
评论 0
private WordListPreference findWordListPreference(final String id) {
final PreferenceGroup prefScreen = getPreferenceScreen();
if (null == prefScreen) {
Log.e(TAG, "Could not find the preference group");
return null;
}
for (int i = prefScreen.getPreferenceCount() - 1; i >= 0; --i) {
final Preference pref = prefScreen.getPreference(i);
if (pref instanceof WordListPreference) {
final WordListPreference wlPref = (WordListPreference)pref;
if (id.equals(wlPref.mWordlistId)) {
return wlPref;
}
}
}
Log.e(TAG, "Could not find the preference for a word list id " + id);
return null;
}
DictionarySettingsFragment.java 文件源码
项目:AOSP-Kayboard-7.1.2
阅读 20
收藏 0
点赞 0
评论 0
void refreshInterface() {
final Activity activity = getActivity();
if (null == activity) return;
final PreferenceGroup prefScreen = getPreferenceScreen();
final Collection<? extends Preference> prefList =
createInstalledDictSettingsCollection(mClientId);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO: display this somewhere
// if (0 != lastUpdate) mUpdateNowPreference.setSummary(updateNowSummary);
refreshNetworkState();
removeAnyDictSettings(prefScreen);
int i = 0;
for (Preference preference : prefList) {
preference.setOrder(i++);
prefScreen.addPreference(preference);
}
}
});
}
InputLanguageSelection.java 文件源码
项目:KeePass2Android
阅读 24
收藏 0
点赞 0
评论 0
@Override
protected void onPause() {
super.onPause();
// Save the selected languages
String checkedLanguages = "";
PreferenceGroup parent = getPreferenceScreen();
int count = parent.getPreferenceCount();
for (int i = 0; i < count; i++) {
CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
if (pref.isChecked()) {
Locale locale = mAvailableLanguages.get(i).locale;
checkedLanguages += get5Code(locale) + ",";
}
}
if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor editor = sp.edit();
editor.putString(KP2AKeyboard.PREF_SELECTED_LANGUAGES, checkedLanguages);
SharedPreferencesCompat.apply(editor);
}
Setting.java 文件源码
项目:MaoMaoRobot
阅读 21
收藏 0
点赞 0
评论 0
private void bind(PreferenceGroup group) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
for (int i = 0; i < group.getPreferenceCount(); i++) {
Preference p = group.getPreference(i);
if (p instanceof PreferenceGroup) {
bind((PreferenceGroup) p);
} else {
if (p instanceof CheckBoxPreference) {
;
} else {
Object val = sp.getAll().get(p.getKey());
p.setSummary(val == null ? "" : ("" + val));
p.setOnPreferenceChangeListener(this);
}
}
}
}
DevelopmentSettings.java 文件源码
项目:haystack
阅读 25
收藏 0
点赞 0
评论 0
@DexAppend
@Override
public void onCreate(Bundle icicle) {
try {
PreferenceGroup pg = (PreferenceGroup) findPreference(
FakeSignatureGlobalUI.DEBUG_APPLICATIONS_CATEGORY_KEY);
if (pg != null) {
TwoStatePreference p = createTwoStatePreference(pg.getContext());
p.setKey(FakeSignatureGlobalUI.SETTING_SECURE_KEY);
p.setTitle(FakeSignatureGlobalUI.SETTING_TITLE);
p.setSummary(FakeSignatureGlobalUI.SETTING_SUMMARY);
p.setPersistent(false);
mResetTwoStatePrefsAdd(p);
mAllPrefs.add(p);
//pg.setOrderingAsAdded(true);
pg.addPreference(p);
mAllowFakeSignatureGlobal = p;
} else {
Log.e("DevelopmentSettings_FakeSignatureGlobalUI", "cannot find 'applications' preference category");
}
} catch (Throwable t) {
Log.e("DevelopmentSettings_FakeSignatureGlobalUI", "onCreate exception", t);
}
}
AutofillPreferences.java 文件源码
项目:AndroidChromium
阅读 21
收藏 0
点赞 0
评论 0
private void rebuildProfileList() {
// Add an edit preference for each current Chrome profile.
PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES);
profileCategory.removeAll();
for (AutofillProfile profile : PersonalDataManager.getInstance().getProfilesForSettings()) {
// Add an item on the current page...
Preference pref = new Preference(getActivity());
pref.setTitle(profile.getFullName());
pref.setSummary(profile.getLabel());
if (profile.getIsLocal()) {
pref.setFragment(AutofillProfileEditor.class.getName());
} else {
pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
pref.setFragment(AutofillServerProfilePreferences.class.getName());
}
Bundle args = pref.getExtras();
args.putString(AUTOFILL_GUID, profile.getGUID());
profileCategory.addPreference(pref);
}
}
AutofillPreferences.java 文件源码
项目:AndroidChromium
阅读 20
收藏 0
点赞 0
评论 0
private void rebuildCreditCardList() {
PreferenceGroup profileCategory =
(PreferenceGroup) findPreference(PREF_AUTOFILL_CREDIT_CARDS);
profileCategory.removeAll();
for (CreditCard card : PersonalDataManager.getInstance().getCreditCardsForSettings()) {
// Add an item on the current page...
Preference pref = new Preference(getActivity());
pref.setTitle(card.getObfuscatedNumber());
pref.setSummary(card.getFormattedExpirationDate(getActivity()));
if (card.getIsLocal()) {
pref.setFragment(AutofillLocalCardEditor.class.getName());
} else {
pref.setFragment(AutofillServerCardEditor.class.getName());
pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
}
Bundle args = pref.getExtras();
args.putString(AUTOFILL_GUID, card.getGUID());
profileCategory.addPreference(pref);
}
}
SettingPreferenceFragment.java 文件源码
项目:Run-With-You
阅读 25
收藏 0
点赞 0
评论 0
private void initPreferences() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
((PreferenceGroup) findPreference(getString(R.string.pref_category_memory_resident))).removePreference(
findPreference(getString(R.string.pref_memory_resident_white_list)));
}
Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
e.onNext(mSettingRepository.getTargetStep());
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(Integer target) throws Exception {
findPreference(getString(R.string.pref_target_step)).setSummary(String.format(Locale.getDefault(),
"每日运动目标:%d步",
target));
}
});
}
SettingsFragment.java 文件源码
项目:instalist-android
阅读 30
收藏 0
点赞 0
评论 0
public void onEvent(final PluginFoundMessage _msg) {
if (mInflater == null || mViewContainer == null) {
Log.e(LOG_TAG, "onEvent: Faster than light, onCreateView was not called yet.");
return;
}
PreferenceGroup preferenceGroup = new PreferenceCategory(mViewContainer.getContext());
preferenceGroup.setTitle(_msg.mName);
View prefView = preferenceGroup.getView(null, mViewContainer);
/*prefView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), _msg.mSettingsActivity);
startActivity(intent);
}
});*/
ViewGroup viewGroup = (ViewGroup) mViewContainer.getChildAt(0);
viewGroup.addView(prefView, viewGroup.getChildCount());
}
GlobalSettingsActivity.java 文件源码
项目:Hupl
阅读 24
收藏 0
点赞 0
评论 0
private List<Preference> getPreferenceList(Preference p, List<Preference> list)
{
if (p instanceof PreferenceCategory || p instanceof PreferenceScreen)
{
PreferenceGroup g = (PreferenceGroup) p;
int pCount = g.getPreferenceCount();
for (int i = 0; i < pCount; i++)
{
getPreferenceList(g.getPreference(i), list);
}
}
else
{
list.add(p);
}
return list;
}
AutofillPreferences.java 文件源码
项目:Vafrinn
阅读 21
收藏 0
点赞 0
评论 0
private void rebuildProfileList() {
// Add an edit preference for each current Chrome profile.
PreferenceGroup profileCategory = (PreferenceGroup) findPreference(PREF_AUTOFILL_PROFILES);
profileCategory.removeAll();
for (AutofillProfile profile : PersonalDataManager.getInstance().getProfiles()) {
// Add an item on the current page...
Preference pref = new Preference(getActivity());
pref.setTitle(profile.getFullName());
pref.setSummary(profile.getLabel());
if (profile.getIsLocal()) {
pref.setFragment(AutofillProfileEditor.class.getName());
} else {
pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
pref.setFragment(AutofillServerProfilePreferences.class.getName());
}
Bundle args = pref.getExtras();
args.putString(AUTOFILL_GUID, profile.getGUID());
profileCategory.addPreference(pref);
}
}
AutofillPreferences.java 文件源码
项目:Vafrinn
阅读 25
收藏 0
点赞 0
评论 0
private void rebuildCreditCardList() {
PreferenceGroup profileCategory =
(PreferenceGroup) findPreference(PREF_AUTOFILL_CREDIT_CARDS);
profileCategory.removeAll();
for (CreditCard card : PersonalDataManager.getInstance().getCreditCards()) {
// Add an item on the current page...
Preference pref = new Preference(getActivity());
pref.setTitle(card.getObfuscatedNumber());
pref.setSummary(card.getFormattedExpirationDate(getActivity()));
if (card.getIsLocal()) {
pref.setFragment(AutofillCreditCardEditor.class.getName());
} else {
pref.setWidgetLayoutResource(R.layout.autofill_server_data_label);
pref.setFragment(AutofillServerCardPreferences.class.getName());
}
Bundle args = pref.getExtras();
args.putString(AUTOFILL_GUID, card.getGUID());
profileCategory.addPreference(pref);
}
}
InputLanguageSelection.java 文件源码
项目:hackerskeyboard
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected void onPause() {
super.onPause();
// Save the selected languages
String checkedLanguages = "";
PreferenceGroup parent = getPreferenceScreen();
int count = parent.getPreferenceCount();
for (int i = 0; i < count; i++) {
CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
if (pref.isChecked()) {
Locale locale = mAvailableLanguages.get(i).locale;
checkedLanguages += get5Code(locale) + ",";
}
}
if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Editor editor = sp.edit();
editor.putString(LatinIME.PREF_SELECTED_LANGUAGES, checkedLanguages);
SharedPreferencesCompat.apply(editor);
}
LatinIMESettings.java 文件源码
项目:hackerskeyboard
阅读 28
收藏 0
点赞 0
评论 0
@Override
protected void onResume() {
super.onResume();
int autoTextSize = AutoText.getSize(getListView());
if (autoTextSize < 1) {
((PreferenceGroup) findPreference(PREDICTION_SETTINGS_KEY))
.removePreference(mQuickFixes);
}
Log.i(TAG, "compactModeEnabled=" + LatinIME.sKeyboardSettings.compactModeEnabled);
if (!LatinIME.sKeyboardSettings.compactModeEnabled) {
CharSequence[] oldEntries = mKeyboardModePortraitPreference.getEntries();
CharSequence[] oldValues = mKeyboardModePortraitPreference.getEntryValues();
if (oldEntries.length > 2) {
CharSequence[] newEntries = new CharSequence[] { oldEntries[0], oldEntries[2] };
CharSequence[] newValues = new CharSequence[] { oldValues[0], oldValues[2] };
mKeyboardModePortraitPreference.setEntries(newEntries);
mKeyboardModePortraitPreference.setEntryValues(newValues);
mKeyboardModeLandscapePreference.setEntries(newEntries);
mKeyboardModeLandscapePreference.setEntryValues(newValues);
}
}
updateSummaries();
}
PreferenceFragment.java 文件源码
项目:AndroidPreferenceActivity
阅读 32
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
}
}