本文整理汇总了Java中android.support.v7.preference.TwoStatePreference类的典型用法代码示例。如果您正苦于以下问题:Java TwoStatePreference类的具体用法?Java TwoStatePreference怎么用?Java TwoStatePreference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TwoStatePreference类属于android.support.v7.preference包,在下文中一共展示了TwoStatePreference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v7.preference.TwoStatePreference; //导入依赖的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);
}
}
示例2: setPreferenceDetails
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
private void setPreferenceDetails(AccountConfig details) {
for (ConfigKey confKey : details.getKeys()) {
Preference pref = findPreference(confKey.key());
if (pref != null) {
if (pref instanceof TwoStatePreference) {
((TwoStatePreference) pref).setChecked(details.getBool(confKey));
} else if (confKey == ConfigKey.ACCOUNT_DTMF_TYPE) {
pref.setDefaultValue(details.get(confKey).contentEquals("overrtp") ? "RTP" : "SIP");
pref.setSummary(details.get(confKey).contentEquals("overrtp") ? "RTP" : "SIP");
} else if (confKey == ConfigKey.RINGTONE_PATH) {
File tmp = new File(details.get(confKey));
pref.setSummary(tmp.getName());
} else {
pref.setSummary(details.get(confKey));
}
}
}
}
示例3: setPreferenceDetails
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
private void setPreferenceDetails(AccountConfig details) {
for (ConfigKey confKey : details.getKeys()) {
Preference pref = findPreference(confKey.key());
if (pref == null) {
continue;
}
if (!confKey.isTwoState()) {
String val = details.get(confKey);
((EditTextPreference) pref).setText(val);
if (pref instanceof PasswordPreference) {
StringBuilder tmp = new StringBuilder();
for (int i = 0; i < val.length(); ++i) {
tmp.append("*");
}
pref.setSummary(tmp.toString());
} else {
pref.setSummary(val);
}
} else {
((TwoStatePreference) pref).setChecked(details.getBool(confKey));
}
}
}
示例4: onPreferenceChange
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final ConfigKey key = ConfigKey.fromString(preference.getKey());
presenter.preferenceChanged(key, newValue);
if (preference instanceof TwoStatePreference) {
presenter.twoStatePreferenceChanged(key, newValue);
} else if (preference instanceof PasswordPreference) {
presenter.passwordPreferenceChanged(key, newValue);
preference.setSummary(TextUtils.isEmpty(newValue.toString()) ? "" : "******");
} else {
presenter.preferenceChanged(key, newValue);
preference.setSummary(newValue.toString());
}
return true;
}
示例5: initMediaRetrieverPref
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
private void initMediaRetrieverPref(boolean storageRetriever) {
TwoStatePreference mediaRetrieverPref =
(TwoStatePreference) findPreference(getString(R.string.pref_key_media_retriever));
mediaRetrieverPref.setChecked(storageRetriever);
mediaRetrieverPref.setOnPreferenceChangeListener(this);
}
示例6: init8BitColorPref
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
private void init8BitColorPref(boolean use8BitColor) {
TwoStatePreference use8BitColorPref =
(TwoStatePreference) findPreference(getString(R.string.pref_key_8_bit_color));
use8BitColorPref.setChecked(use8BitColor);
use8BitColorPref.setOnPreferenceChangeListener(this);
}
示例7: initCameraShortcutPref
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
private void initCameraShortcutPref(boolean cameraShortcut) {
TwoStatePreference cameraShortcutPref =
(TwoStatePreference) findPreference(getString(R.string.pref_key_camera_shortcut));
cameraShortcutPref.setChecked(cameraShortcut);
cameraShortcutPref.setOnPreferenceChangeListener(this);
}
示例8: configureHandleLinks
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
private void configureHandleLinks() {
PreferenceCategory category =
(PreferenceCategory) findPreference(PREF_ACCOUNT_EXTERNAL_CATEGORY);
mHandleLinks = (TwoStatePreference) findPreference(PREF_ACCOUNT_HANDLE_LINKS);
if (!ModelHelper.canAccountHandleUrls(getContext(), mAccount)) {
if (mHandleLinks != null) {
category.removePreference(mHandleLinks);
mHandleLinks = null;
}
} else {
mHandleLinks.setChecked(Preferences.isAccountHandleLinks(getContext(), mAccount)
&& ModelHelper.isAccountUrlHandlingEnabled(getContext(), mAccount));
mHandleLinks.setOnPreferenceChangeListener(this);
}
}
示例9: createTwoStatePreference
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
@DexAdd
private TwoStatePreference createTwoStatePreference(Context context) {
if (useSwitchPreference()) {
return new SwitchPreference(context);
} else {
return new CheckBoxPreference(context);
}
}
示例10: mResetTwoStatePrefsAdd
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
@DexAdd
private boolean mResetTwoStatePrefsAdd(TwoStatePreference preference) {
if (useSwitchPreference()) {
return mResetSwitchPrefs.add((SwitchPreference) preference);
} else {
return mResetCbPrefs.add((CheckBoxPreference) preference);
}
}
示例11: updateTwoStatePreference
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
@DexAdd
private void updateTwoStatePreference(TwoStatePreference preference, boolean value) {
if (useSwitchPreference()) {
updateSwitchPreference((SwitchPreference) preference, value);
} else {
updateCheckBox((CheckBoxPreference) preference, value);
}
}
示例12: onCreatePreferences
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preferences);
remindersDaysEditTextPreference = (EditTextPreference) findPreference(getString(R.string.pref_reminders_days_key));
Preference openCalendar = findPreference(getString(R.string.pref_open_calendar_key));
openCalendar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@SuppressLint("NewApi")
@Override
public boolean onPreferenceClick(Preference preference) {
IntentCall.openCalendarAt(getContext(), new Date());
return true;
}
});
accountResolver = CalendarAccount.getAccount(getContext());
preferenceCreateCalendar = (TwoStatePreference) findPreference(getString(R.string.pref_create_calendar_key));
preferenceCreateCalendar.setDefaultValue(false);
preferenceCreateCalendar.setOnPreferenceClickListener(onPreferenceCalendarClick);
preferenceSpecial = (TwoStatePreference) findPreference(getString(R.string.pref_special_service_key));
preferenceSpecial.setDefaultValue(false);
if (!BuildConfig.FULL_VERSION) {
// Disable switch and show pro dialog if free version
preferenceSpecial.setOnPreferenceClickListener(onPreferenceProFeatureClick);
} else {
preferenceSpecial.setOnPreferenceClickListener(onPreferenceSendSmsClick);
}
TwoStatePreference preferenceHideInactive = (TwoStatePreference) findPreference(getString(R.string.pref_hide_inactive_features_key));
if (!BuildConfig.FULL_VERSION) {
preferenceHideInactive.setOnPreferenceClickListener(onPreferenceProFeatureClick);
}
}
示例13: onPreferenceTreeClick
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey() == null)
return false;
switch (preference.getKey()){
case "enable_headset_detection":
((PreferencesActivity)getActivity()).detectHeadset(((TwoStatePreference) preference).isChecked());
return true;
case "enable_steal_remote_control":
PlaybackService.Client.restartService(getActivity());
return true;
}
return super.onPreferenceTreeClick(preference);
}
示例14: setup
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
/**
* Set an initial value. Updates the summary to match.
*/
private void setup(String key, Object adminSetting) {
final Preference pref = findPreference(key);
final DpcPreferenceBase dpcPref = (DpcPreferenceBase) pref;
// Disable preferences that don't apply to the parent profile
dpcPref.setCustomConstraint(
() -> Keys.NOT_APPLICABLE_TO_PARENT.contains(key) && isParentProfileInstance()
? R.string.not_for_parent_profile
: NO_CUSTOM_CONSTRIANT
);
// We do not allow user to add trust agent config in pre-N devices in managed profile.
if (!BuildCompat.isAtLeastN() && key.equals(Keys.SET_TRUST_AGENT_CONFIG)) {
dpcPref.setAdminConstraint(DpcPreferenceHelper.ADMIN_DEVICE_OWNER);
return;
}
// Set up initial state and possibly a descriptive summary of said state.
if (pref instanceof EditTextPreference) {
String stringValue = (adminSetting != null ? adminSetting.toString() : null);
if (adminSetting instanceof Number && "0".equals(stringValue)) {
stringValue = null;
}
((EditTextPreference) pref).setText(stringValue);
pref.setSummary(stringValue);
} else if (pref instanceof TwoStatePreference) {
((TwoStatePreference) pref).setChecked((Boolean) adminSetting);
}
// Start listening for change events.
pref.setOnPreferenceChangeListener(this);
pref.setOnPreferenceClickListener(this);
}
示例15: setUpMediaWikiSettings
import android.support.v7.preference.TwoStatePreference; //导入依赖的package包/类
private void setUpMediaWikiSettings() {
Preference uriPreference = findPreference(context.getString(R.string.preference_key_mediawiki_base_uri));
uriPreference.setOnPreferenceChangeListener(setMediaWikiBaseUriChangeListener);
TwoStatePreference multiLangPreference
= (TwoStatePreference) findPreference(context.getString(R.string.preference_key_mediawiki_base_uri_supports_lang_code));
multiLangPreference.setOnPreferenceChangeListener(setMediaWikiMultiLangSupportChangeListener);
}