本文整理匯總了Java中android.preference.PreferenceGroup.findPreference方法的典型用法代碼示例。如果您正苦於以下問題:Java PreferenceGroup.findPreference方法的具體用法?Java PreferenceGroup.findPreference怎麽用?Java PreferenceGroup.findPreference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.preference.PreferenceGroup
的用法示例。
在下文中一共展示了PreferenceGroup.findPreference方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addRemovePreference
import android.preference.PreferenceGroup; //導入方法依賴的package包/類
private boolean addRemovePreference(boolean add, String key, Preference preference, PreferenceGroup category) {
if (!add && category.findPreference(key) != null) {
category.removePreference(preference);
} else if (add && category.findPreference(key) == null) {
category.addPreference(preference);
}
return add;
}
示例2: addPreferencesOnScreen
import android.preference.PreferenceGroup; //導入方法依賴的package包/類
@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
Context context = preferenceGroup.getContext();
addPasscodePreference(preferenceGroup);
CheckBoxPreference newRecaptchaPref = new LazyPreferences.CheckBoxPreference(context);
newRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha);
newRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_summary);
newRecaptchaPref.setKey(getSharedKey(PREF_KEY_NEW_RECAPTCHA));
newRecaptchaPref.setDefaultValue(NEW_RECAPTCHA_DEFAULT);
preferenceGroup.addPreference(newRecaptchaPref);
final CheckBoxPreference fallbackRecaptchaPref = new LazyPreferences.CheckBoxPreference(context);
fallbackRecaptchaPref.setTitle(R.string.fourchan_prefs_new_recaptcha_fallback);
fallbackRecaptchaPref.setSummary(R.string.fourchan_prefs_new_recaptcha_fallback_summary);
fallbackRecaptchaPref.setKey(getSharedKey(PREF_KEY_NEW_RECAPTCHA_FALLBACK));
fallbackRecaptchaPref.setDefaultValue(false);
preferenceGroup.addPreference(fallbackRecaptchaPref);
fallbackRecaptchaPref.setDependency(getSharedKey(PREF_KEY_NEW_RECAPTCHA));
addPasswordPreference(preferenceGroup);
addHttpsPreference(preferenceGroup, true);
addProxyPreferences(preferenceGroup);
final CheckBoxPreference proxyPreference = (CheckBoxPreference) preferenceGroup.findPreference(getSharedKey(PREF_KEY_USE_PROXY));
fallbackRecaptchaPref.setEnabled(!proxyPreference.isChecked());
proxyPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
fallbackRecaptchaPref.setEnabled(!proxyPreference.isChecked());
if (proxyPreference.isChecked() && !fallbackRecaptchaPref.isChecked()) fallbackRecaptchaPref.setChecked(true);
return false;
}
});
}