本文整理匯總了Java中android.preference.CheckBoxPreference.setOnPreferenceChangeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java CheckBoxPreference.setOnPreferenceChangeListener方法的具體用法?Java CheckBoxPreference.setOnPreferenceChangeListener怎麽用?Java CheckBoxPreference.setOnPreferenceChangeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.preference.CheckBoxPreference
的用法示例。
在下文中一共展示了CheckBoxPreference.setOnPreferenceChangeListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.prefs = getSharedPreferences(Common.PREFS, Context.MODE_WORLD_READABLE);
addPreferencesFromResource(R.xml.preference);
mSwith = (SwitchPreference) findPreference("enable_toast");
mStyle = (ListPreference) findPreference("style_key");
mAnimation = (ListPreference) findPreference("animation_key");
mEnable_icon = (CheckBoxPreference) findPreference("enable_icon");
mGithub = findPreference("viewsource");
mSwith.setOnPreferenceChangeListener(this);
mStyle.setOnPreferenceChangeListener(this);
mAnimation.setOnPreferenceChangeListener(this);
mEnable_icon.setOnPreferenceChangeListener(this);
mGithub.setOnPreferenceClickListener(this);
}
示例2: onCreate
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
addPreferencesFromResource(R.xml.preferences_app_protection);
masterSecret = getArguments().getParcelable("master_secret");
disablePassphrase = (CheckBoxPreference) this.findPreference("pref_enable_passphrase_temporary");
this.findPreference(TextSecurePreferences.CHANGE_PASSPHRASE_PREF)
.setOnPreferenceClickListener(new ChangePassphraseClickListener());
this.findPreference(TextSecurePreferences.PASSPHRASE_TIMEOUT_INTERVAL_PREF)
.setOnPreferenceClickListener(new PassphraseIntervalClickListener());
this.findPreference(PREFERENCE_CATEGORY_BLOCKED)
.setOnPreferenceClickListener(new BlockedContactsClickListener());
disablePassphrase
.setOnPreferenceChangeListener(new DisablePassphraseClickListener());
}
示例3: setDynamicMsgBgColor
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void setDynamicMsgBgColor(final CheckBoxPreference checkBoxPreference, final ColorPreference hue, final ColorPreference hueDark)
{
hue.setEnabled(!checkBoxPreference.isChecked());
hueDark.setEnabled(!checkBoxPreference.isChecked());
final CheckBoxPreference darkThemePref = (CheckBoxPreference) findPreference("dark_theme");
checkBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(Preference preference, Object o)
{
if (darkThemePref.isChecked())
{
hueDark.setEnabled(!(boolean) o);
hue.setEnabled(false);
}
else
{
hue.setEnabled(!(boolean) o);
hueDark.setEnabled(false);
}
return true;
}
});
}
示例4: setSameFabColor
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void setSameFabColor(final CheckBoxPreference sameFabColor, final ColorPreference hue)
{
sameFabColor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(Preference preference, Object o)
{
if ((boolean) o)
{
hue.setEnabled(false);
}
else
{
hue.setEnabled(true);
}
return true;
}
});
}
示例5: onCreate
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.custom_prefs);
// This sample app uses shared preferences to maintain app restriction settings. Your app
// can use other methods to maintain the settings.
mBooleanPref = (CheckBoxPreference) findPreference(KEY_BOOLEAN_PREF);
mChoicePref = (ListPreference) findPreference(KEY_CHOICE_PREF);
mMultiPref = (MultiSelectListPreference) findPreference(KEY_MULTI_PREF);
mBooleanPref.setOnPreferenceChangeListener(this);
mChoicePref.setOnPreferenceChangeListener(this);
mMultiPref.setOnPreferenceChangeListener(this);
setRetainInstance(true);
}
示例6: onCreate
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.dev_options);
CheckBoxPreference leakPref = (CheckBoxPreference) findPreference(KEY_LEAK_CANARY);
if (isDebugVersion()) {
leakPref.setChecked(isLeakCanaryEnabled(getActivity()));
leakPref.setOnPreferenceChangeListener((preference, newValue) -> {
final SharedPreferences prefs = getPrefs(preference.getContext());
prefs.edit().putBoolean(KEY_LEAK_CANARY, (Boolean) newValue).apply();
return true;
});
} else {
getPreferenceScreen().removePreference(leakPref);
}
Preference prefTrackerPref = findPreference(KEY_PERF_DEBUG_SCREEN);
prefTrackerPref.setOnPreferenceClickListener(preference -> {
WhistlePunkApplication.getPerfTrackerProvider(getContext())
.startPerfTrackerEventDebugActivity(getContext());
return true;
});
}
示例7: initializeCalendarReminderPreference
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void initializeCalendarReminderPreference() {
CheckBoxPreference calendarReminderPreference = (CheckBoxPreference) findPreference(getString(R.string.p_calendar_reminders));
calendarReminderPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (newValue == null) {
return false;
}
if (!(Boolean) newValue) {
return true;
}
if (permissionRequestor.requestCalendarPermissions()) {
backgroundScheduler.scheduleCalendarNotifications();
return true;
}
return false;
}
});
calendarReminderPreference.setChecked(calendarReminderPreference.isChecked() && permissionChecker.canAccessCalendars());
}
示例8: createCheckBoxPreference
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
/**
* Create a SwitchPreference for the specified preference
* @param titleResId resource ID to use for the title
* @param summaryResId resource ID to use for the summary
* @param key preference key
* @return newly created preference
*/
private CheckBoxPreference createCheckBoxPreference(@StringRes int titleResId, @StringRes int summaryResId, Settings.Key key) {
final CheckBoxPreference checkBoxPreference = new CheckBoxPreference(getActivity());
checkBoxPreference.setDefaultValue(mSettings.getDefault(key));
checkBoxPreference.setKey(key.name());
checkBoxPreference.setSummary(summaryResId);
checkBoxPreference.setTitle(titleResId);
checkBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
checkBoxPreference.setChecked((boolean) newValue);
return true;
}
});
return checkBoxPreference;
}
示例9: onCreate
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO: Implement this method
super.onCreate(savedInstanceState);
//this.getListView().setBackgroundResource(R.color.deepskyblue);
addPreferencesFromResource(R.xml.settings);
cb_use_first_size = (CheckBoxPreference)findPreference("cb_use_first_size");
edit_pic_width = (EditTextPreference)findPreference("edit_pic_width");
edit_pic_height = (EditTextPreference)findPreference("edit_pic_height");
isSelected=cb_use_first_size.isChecked();
setTwoEditEnabled();
cb_use_first_size.setOnPreferenceChangeListener(new OnPreferenceChangeListener()
{
public boolean onPreferenceChange(Preference p1, Object p2)
{
if (p1.getKey().equals("cb_use_first_size"))
{
isSelected=!cb_use_first_size.isChecked();
setTwoEditEnabled();
}
return true;
}
});
}
示例10: initializePushMessagingToggle
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void initializePushMessagingToggle() {
CheckBoxPreference preference = (CheckBoxPreference)this.findPreference(PUSH_MESSAGING_PREF);
if (TextSecurePreferences.isPushRegistered(getActivity())) {
preference.setChecked(true);
preference.setSummary(TextSecurePreferences.getLocalNumber(getActivity()));
} else {
preference.setChecked(false);
preference.setSummary(R.string.preferences__free_private_messages_and_calls);
}
preference.setOnPreferenceChangeListener(new PushMessagingClickListener());
}
示例11: loadPreferences
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void loadPreferences() {
addPreferencesFromResource(R.xml.preferences);
final PreferenceScreen screen = getPreferenceScreen();
mCheckBoxEnabled = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_enabled));
mVibratePart = (ListPreference)screen.findPreference(getString(R.string.preference_vibrate_parts));
mTestText = (EditTextPreference)screen.findPreference(getString(R.string.preference_test));
mVibrateCounts = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_counts));
mDotLength = (BetterSeekBarPreference)screen.findPreference(getString(R.string.preference_dot_length));
mCheckBoxEnabled.setOnPreferenceChangeListener(mEnabledListener);
mVibratePart.setOnPreferenceChangeListener(mVibratePartListener);
//Trigger summary update
mVibratePartListener.onPreferenceChange(mVibratePart, mVibratePart.getValue());
mTestText.setOnPreferenceChangeListener(mTestTextListener);
mScreenOffOnly = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_screen_off_only));
mActiveNormal = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_normal));
mActiveVibrate = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_vibrate));
mActiveSilent = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_vibrate_silent));
//mCheckBoxInputEnabled = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_input_enabled));
//mCheckBoxInputEnabled.setOnPreferenceChangeListener(mInputEnabledListener);
final DialogPreference about = (DialogPreference)screen.findPreference(getString(R.string.preference_about));
about.setDialogLayoutResource(R.layout.about);
try {
final String version = getPackageManager().getPackageInfo("com.jakewharton.smsmorse", PackageManager.GET_META_DATA).versionName;
about.setDialogTitle(getString(R.string.app_name) + " v" + version);
} catch (Exception e) {}
}
示例12: setAppBarColorChange
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void setAppBarColorChange(CheckBoxPreference checkBoxPreference)
{
checkBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(Preference preference, Object newValue)
{
boolean pref = Boolean.parseBoolean(newValue.toString());
mSharedPrefs.edit().putBoolean("dynamicallyColorBar", pref).apply();
return true;
}
});
}
示例13: initPrefs
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void initPrefs() {
// mPreferences storage
mThemeOptions = this.getResources().getStringArray(R.array.themes);
mCurrentTheme = mPreferenceManager.getUseTheme();
mTheme = findPreference(SETTINGS_THEME);
Preference textSize = findPreference(SETTINGS_TEXTSIZE);
CheckBoxPreference cbStatus = (CheckBoxPreference) findPreference(SETTINGS_HIDESTATUSBAR);
CheckBoxPreference cbFullScreen = (CheckBoxPreference) findPreference(SETTINGS_FULLSCREEN);
CheckBoxPreference cbViewPort = (CheckBoxPreference) findPreference(SETTINGS_VIEWPORT);
CheckBoxPreference cbOverview = (CheckBoxPreference) findPreference(SETTINGS_OVERVIEWMODE);
CheckBoxPreference cbReflow = (CheckBoxPreference) findPreference(SETTINGS_REFLOW);
CheckBoxPreference cbBlackStatus = (CheckBoxPreference) findPreference(SETTINGS_BLACK_STATUS);
CheckBoxPreference cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS);
CheckBoxPreference cbSwapTabs = (CheckBoxPreference) findPreference(SETTINGS_SWAPTABS);
mTheme.setOnPreferenceClickListener(this);
textSize.setOnPreferenceClickListener(this);
cbStatus.setOnPreferenceChangeListener(this);
cbFullScreen.setOnPreferenceChangeListener(this);
cbViewPort.setOnPreferenceChangeListener(this);
cbOverview.setOnPreferenceChangeListener(this);
cbReflow.setOnPreferenceChangeListener(this);
cbBlackStatus.setOnPreferenceChangeListener(this);
cbDrawerTabs.setOnPreferenceChangeListener(this);
cbSwapTabs.setOnPreferenceChangeListener(this);
cbStatus.setChecked(mPreferenceManager.getHideStatusBarEnabled());
cbFullScreen.setChecked(mPreferenceManager.getFullScreenEnabled());
cbViewPort.setChecked(mPreferenceManager.getUseWideViewportEnabled());
cbOverview.setChecked(mPreferenceManager.getOverviewModeEnabled());
cbReflow.setChecked(mPreferenceManager.getTextReflowEnabled());
cbBlackStatus.setChecked(mPreferenceManager.getUseBlackStatusBar());
cbDrawerTabs.setChecked(mPreferenceManager.getShowTabsInDrawer(true));
cbSwapTabs.setChecked(mPreferenceManager.getBookmarksAndTabsSwapped());
mTheme.setSummary(mThemeOptions[mPreferenceManager.getUseTheme()]);
}
示例14: GeneralSettings
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void GeneralSettings() {
CheckBoxPreference mCbEnabledVolumeKey = (CheckBoxPreference) findPreference(Config.ENABLED_VOLUME_KEY);
mCbEnabledVolumeKey.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference p, Object o) {
displayToast((boolean) o);
return true;
}
});
findPreference(Config.CLOSE_ADVANCED_FUNCTIONS).setOnPreferenceChangeListener(launchService);
}
示例15: setAutoRenewEvent
import android.preference.CheckBoxPreference; //導入方法依賴的package包/類
private void setAutoRenewEvent(){
final CheckBoxPreference autorenewPreference = (CheckBoxPreference) findPreference(getString(R.string.pref_library_autorenew));
autorenewPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Returns true if the value must change
boolean willTurnOnAutorenew = newValue.toString().equals("true");
final LibraryRenewAlarmBroadcastReceiver alarmBroadcastReceiver = new LibraryRenewAlarmBroadcastReceiver();
if(willTurnOnAutorenew){
LibraryAutoRenewDialogFragment autoRenewDialogFragment = new LibraryAutoRenewDialogFragment();
autoRenewDialogFragment.setRenewDialogResponse(new LibraryAutoRenewDialogFragment.RenewDialogResponse() {
@Override
public void onAutoRenewAccepted() {
autorenewPreference.setChecked(true);
alarmBroadcastReceiver.setAlarm(getActivity());
}
@Override
public void onAutoRenewDenied() {
autorenewPreference.setChecked(false);
}
});
autoRenewDialogFragment.show(MainPreferencesActivity.mFragmentManager, "libTag");
return false;
}
else{
// Cancel autorenew
alarmBroadcastReceiver.cancelAlarm(getActivity());
return true;
}
}
});
}