本文整理汇总了Java中android.preference.PreferenceGroup.addPreference方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceGroup.addPreference方法的具体用法?Java PreferenceGroup.addPreference怎么用?Java PreferenceGroup.addPreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.PreferenceGroup
的用法示例。
在下文中一共展示了PreferenceGroup.addPreference方法的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);
}
示例2: replaceAllCheckBoxPreferencesBySwitchPreferences
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
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);
}
}
}
}
示例3: rebuildProfileList
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
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);
}
}
示例4: rebuildCreditCardList
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
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);
}
}
示例5: createUserDictSettings
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* 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));
}
}
}
示例6: addSwitchPreferenceBasedOnCheckBoxPreference
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
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());
}
示例7: onCreate
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@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);
}
}
示例8: rebuildProfileList
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
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);
}
}
示例9: rebuildCreditCardList
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
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);
}
}
示例10: 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);
}
}
}
}
示例11: addPasswordPreference
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
/**
* Добавить в группу параметров (на экран/в категорию) параметр задания пароля для удаления постов/файлов
* @param group группа, на которую добавляется параметр
*/
protected void addPasswordPreference(PreferenceGroup group) {
final Context context = group.getContext();
EditTextPreference passwordPref = new EditTextPreference(context) {
@Override
protected void showDialog(Bundle state) {
if (createPassword()) {
setText(getDefaultPassword());
}
super.showDialog(state);
}
};
passwordPref.setTitle(R.string.pref_password_title);
passwordPref.setDialogTitle(R.string.pref_password_title);
passwordPref.setSummary(R.string.pref_password_summary);
passwordPref.setKey(getSharedKey(PREF_KEY_PASSWORD));
passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
passwordPref.getEditText().setSingleLine();
passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) });
group.addPreference(passwordPref);
}
示例12: addDomainPreferences
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void addDomainPreferences(PreferenceGroup group) {
Context context = group.getContext();
Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) {
domain = (String) newValue;
if (domain.length() == 0) domain = DEFAULT_DOMAIN;
loadHanabiraCookie();
return true;
}
return false;
}
};
EditTextPreference domainPref = new EditTextPreference(context);
domainPref.setTitle(R.string.pref_domain);
domainPref.setDialogTitle(R.string.pref_domain);
domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
domainPref.getEditText().setHint(DEFAULT_DOMAIN);
domainPref.getEditText().setSingleLine();
domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
domainPref.setOnPreferenceChangeListener(updateDomainListener);
group.addPreference(domainPref);
}
示例13: addRatingPreference
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
private void addRatingPreference(PreferenceGroup group) {
Context context = group.getContext();
Preference.OnPreferenceChangeListener updateRatingListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference.getKey().equals(getSharedKey(PREF_KEY_MAX_RATING))) {
setMaxRating((String) newValue);
return true;
}
return false;
}
};
ListPreference ratingPref = new LazyPreferences.ListPreference(context);
ratingPref.setTitle(R.string.dobrochan_prefs_max_rating);
ratingPref.setSummary(preferences.getString(getSharedKey(PREF_KEY_MAX_RATING), "R-15"));
ratingPref.setEntries(RATINGS);
ratingPref.setEntryValues(RATINGS);
ratingPref.setDefaultValue("R-15");
ratingPref.setKey(getSharedKey(PREF_KEY_MAX_RATING));
ratingPref.setOnPreferenceChangeListener(updateRatingListener);
group.addPreference(ratingPref);
}
示例14: addKompturcodePreference
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
public void addKompturcodePreference(PreferenceGroup preferenceGroup) {
Context context = preferenceGroup.getContext();
EditTextPreference kompturcodePreference = new EditTextPreference(context);
kompturcodePreference.setTitle(R.string.kraut_prefs_kompturcode);
kompturcodePreference.setDialogTitle(R.string.kraut_prefs_kompturcode);
kompturcodePreference.setSummary(R.string.kraut_prefs_kompturcode_summary);
kompturcodePreference.setKey(getSharedKey(PREF_KEY_KOMPTURCODE_COOKIE));
kompturcodePreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
setKompturcodeCookie((String) newValue);
return true;
}
});
preferenceGroup.addPreference(kompturcodePreference);
}
示例15: addPreferencesOnScreen
import android.preference.PreferenceGroup; //导入方法依赖的package包/类
@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
Context context = preferenceGroup.getContext();
addPasswordPreference(preferenceGroup);
CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context);
onionPref.setTitle(R.string.pref_use_onion);
onionPref.setSummary(R.string.pref_use_onion_summary);
onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION));
onionPref.setDefaultValue(false);
onionPref.setDisableDependentsState(true);
preferenceGroup.addPreference(onionPref);
EditTextPreference domainPref = new EditTextPreference(context);
domainPref.setTitle(R.string.pref_domain);
domainPref.setDialogTitle(R.string.pref_domain);
domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
domainPref.getEditText().setHint(DEFAULT_DOMAIN);
domainPref.getEditText().setSingleLine();
domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
preferenceGroup.addPreference(domainPref);
domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION));
addProxyPreferences(preferenceGroup);
}