当前位置: 首页>>代码示例>>Java>>正文


Java CheckBoxPreference.setOnPreferenceClickListener方法代码示例

本文整理汇总了Java中android.preference.CheckBoxPreference.setOnPreferenceClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBoxPreference.setOnPreferenceClickListener方法的具体用法?Java CheckBoxPreference.setOnPreferenceClickListener怎么用?Java CheckBoxPreference.setOnPreferenceClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.preference.CheckBoxPreference的用法示例。


在下文中一共展示了CheckBoxPreference.setOnPreferenceClickListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupDisableSoundCheckBox

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void setupDisableSoundCheckBox() {
    final CheckBoxPreference disableSoundCheckbox = (CheckBoxPreference)
            findPreference(DISABLE_SOUND_AND_VIBRATION);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !isNotificationPolicyAccessGranted()) {
        disableSoundCheckbox.setOnPreferenceClickListener(
                new Preference.OnPreferenceClickListener() {
                    @Override
                    public boolean onPreferenceClick(Preference preference) {
                        requestNotificationPolicyAccess();
                        if(!isNotificationPolicyAccessGranted()) {
                            updateDisableSoundCheckBoxState(false);
                        }
                        return false;
                    }
                }
        );
    } else {
        updateDisableSoundCheckBoxSummary(true);
    }
}
 
开发者ID:goodtime-productivity,项目名称:Goodtime,代码行数:21,代码来源:SettingsFragment.java

示例2: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);
	setTitle(R.string.replaygain);
	addPreferencesFromResource(R.xml.preference_replaygain);
	
	cbTrackReplayGain = (CheckBoxPreference)findPreference(PrefKeys.ENABLE_TRACK_REPLAYGAIN);
	cbAlbumReplayGain = (CheckBoxPreference)findPreference(PrefKeys.ENABLE_ALBUM_REPLAYGAIN);
	sbGainBump = (SeekBarPreference)findPreference(PrefKeys.REPLAYGAIN_BUMP);
	sbUntaggedDebump = (SeekBarPreference)findPreference(PrefKeys.REPLAYGAIN_UNTAGGED_DEBUMP);
	
	Preference.OnPreferenceClickListener pcListener = new Preference.OnPreferenceClickListener() {
		public boolean onPreferenceClick(Preference preference) {
			updateConfigWidgets();
			return false;
		}
	};
	
	cbTrackReplayGain.setOnPreferenceClickListener(pcListener);
	cbAlbumReplayGain.setOnPreferenceClickListener(pcListener);
	updateConfigWidgets();
}
 
开发者ID:owoc,项目名称:teardrop,代码行数:25,代码来源:PreferencesActivity.java

示例3: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
	PreferenceManager manager = getPreferenceManager();
	manager.setSharedPreferencesName(PREFS_COMMON); // configure preferences
	addPreferencesFromResource(R.layout.prefs_brightness);
	
	CheckBoxPreference checkbox = (CheckBoxPreference) findPreference(PREF_LIGHT_SENSOR);
	checkbox.setOnPreferenceClickListener(this);
	
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:12,代码来源:BrightnessPrefs.java

示例4: setupCheckboxes

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void setupCheckboxes() {
    firstBox = (CheckBoxPreference) findPreference("deck1_key");
    secondBox = (CheckBoxPreference) findPreference("deck2_key");
    thirdBox = (CheckBoxPreference) findPreference(("custom_deck_key"));
    checkBoxes.add(firstBox);
    checkBoxes.add(secondBox);
    checkBoxes.add(thirdBox);
    for (CheckBoxPreference checkbox : checkBoxes) {
        checkbox.setOnPreferenceClickListener(this);
    }
}
 
开发者ID:SecUSo,项目名称:privacy-friendly-memo-game,代码行数:12,代码来源:DeckChoiceActivity.java

示例5: initPrivilegedInstallerPreference

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
/**
 * Initializes SystemInstaller preference, which can only be enabled when F-Droid is installed as a system-app
 */
private void initPrivilegedInstallerPreference() {
    final CheckBoxPreference pref = (CheckBoxPreference) findPreference(Preferences.PREF_PRIVILEGED_INSTALLER);

    // This code will be run each time the activity is resumed, and so we may have already removed
    // this preference.
    if (pref == null) {
        return;
    }

    Preferences p = Preferences.get();
    boolean enabled = p.isPrivilegedInstallerEnabled();
    boolean installed = PrivilegedInstaller.isExtensionInstalledCorrectly(getActivity())
            == PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES;

    // On later versions of Android the privileged installer needs to be installed
    // via flashing an update.zip or building into a rom. As such, if it isn't installed
    // by the time the user boots, opens F-Droid, and views this settings page, then there
    // is no benefit showing it to them (it will only be disabled and we can't offer any
    // way to easily install from here.
    if (Build.VERSION.SDK_INT > 19 && !installed) {
        PreferenceCategory other = (PreferenceCategory) findPreference("pref_category_other");
        if (pref != null) {
            other.removePreference(pref);
        }
    } else {
        pref.setEnabled(installed);
        pref.setDefaultValue(installed);
        pref.setChecked(enabled && installed);

        pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
            @Override
            public boolean onPreferenceClick(Preference preference) {
                SharedPreferences.Editor editor = pref.getSharedPreferences().edit();
                if (pref.isChecked()) {
                    editor.remove(Preferences.PREF_PRIVILEGED_INSTALLER);
                } else {
                    editor.putBoolean(Preferences.PREF_PRIVILEGED_INSTALLER, false);
                }
                editor.apply();
                return true;
            }
        });
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:48,代码来源:PreferencesFragment.java

示例6: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.app_selector_screen);

    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("apps");
    sharedPreferencesPackageNames = getActivity().getSharedPreferences("myPackageNames", MODE_PRIVATE);


    Set<String> all = sharedPreferencesPackageNames.getStringSet(getString(R.string.shared_pref_key_package_name_all), null);
    Set<String> selected = sharedPreferencesPackageNames.getStringSet(getString(R.string.shared_pref_key_package_name_selected), null);

    CheckBoxPreference a = new CheckBoxPreference(getContext());
    a.setKey(getContext().getString(R.string.string_all_key));
    a.setTitle(R.string.string_all_apps);
    if (selected != null){
        if (selected.contains(getContext().getString(R.string.string_all_key))){
            a.setChecked(true);
        }
    }
    a.setOnPreferenceClickListener(this);
    preferenceCategory.addPreference(a);

    if (all != null){
        for(String s: all){
            CheckBoxPreference p = new CheckBoxPreference(getContext());
            p.setKey(s);
            p.setSummary(s);
            p.setEnabled(!a.isChecked());

            if (selected != null){
                if (selected.contains(s)){
                    p.setChecked(true);
                }
            }

            p.setTitle(Utils.getAppName(getContext(), s));
            p.setOnPreferenceClickListener(this);
            preferenceCategory.addPreference(p);
        }
    }

    String title = preferenceCategory.getTitle().toString();

    // all devices with android 8.1 and Pixel 2 (XL) on 8.0 and onward are using "using battery" instead of "running in the background"
    if (Build.VERSION.SDK_INT >= 27 || Build.MODEL.equals("Pixel 2") || Build.MODEL.equals("Pixel 2 XL")){
        title = title.replace("%s", "\"" + getString(R.string.string_app_name_replace_using_battery) + "\"");
    }else{
        title = title.replace("%s", "\"" + getString(R.string.string_app_name_replace_running_in_the_background) + "\"");
    }

    preferenceCategory.setTitle(title);

}
 
开发者ID:iboalali,项目名称:sysnotifsnooze,代码行数:55,代码来源:AppSelectorActivity.java

示例7: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
	boolean dark_theme = false;
	
	Bundle extras = getIntent().getExtras();
	if(extras != null)
	{
		dark_theme = extras.getBoolean("com.kmk.Referey.dark_theme");

	}
	
    if ( dark_theme ) {
   		setTheme(android.R.style.Theme_Black);
   	} else {
   		setTheme(android.R.style.Theme_Light);
   	}
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    alternative_path = (CheckBoxPreference) findPreference("alternative_path");
    preserve_path = findPreference("preserve_path");
    remove_path = findPreference("remove_path");
    
   	if ( alternative_path.isChecked() == true ) {
   		preserve_path.setEnabled(false);
   		remove_path.setEnabled(true);
   	} else {
   		preserve_path.setEnabled(true);
   		remove_path.setEnabled(false);
   	}
    
    alternative_path.setOnPreferenceClickListener(new OnPreferenceClickListener() {
        public boolean onPreferenceClick(Preference preference) {
            if ( preference.getKey().contains("alternative_path") ) {
            	if ( alternative_path.isChecked() == true ) {
            		preserve_path.setEnabled(false);
            		remove_path.setEnabled(true);
            	} else {
            		preserve_path.setEnabled(true);
            		remove_path.setEnabled(false);	            	}
            	return true;
            } else {
            	return false;
            }
        }
    });

}
 
开发者ID:kleinkm,项目名称:Referey,代码行数:50,代码来源:Preferences.java


注:本文中的android.preference.CheckBoxPreference.setOnPreferenceClickListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。