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


Java CheckBoxPreference.isChecked方法代码示例

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


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

示例1: onPause

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
protected void onPause() {
    super.onPause();
    // Save the selected languages
    String checkedLanguages = "";
    PreferenceGroup parent = getPreferenceScreen();
    int count = parent.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
        if (pref.isChecked()) {
            Locale locale = mAvailableLanguages.get(i).locale;
            checkedLanguages += get5Code(locale) + ",";
        }
    }
    if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Editor editor = sp.edit();
    editor.putString(KP2AKeyboard.PREF_SELECTED_LANGUAGES, checkedLanguages);
    SharedPreferencesCompat.apply(editor);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:21,代码来源:InputLanguageSelection.java

示例2: onSharedPreferenceChanged

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    PreferenceKeys preferenceKeys = new PreferenceKeys(getResources());
    if(key.equals(preferenceKeys.night_mode_pref_key)){
        SharedPreferences themePreferences = getActivity().getSharedPreferences(MainActivity.THEME_PREFERENCES, Context.MODE_PRIVATE);
        SharedPreferences.Editor themeEditor = themePreferences.edit();
        //We tell our MainLayout to recreate itself because mode has changed
        themeEditor.putBoolean(MainActivity.RECREATE_ACTIVITY, true);

        CheckBoxPreference checkBoxPreference = (CheckBoxPreference)findPreference(preferenceKeys.night_mode_pref_key);
        if(checkBoxPreference.isChecked()){
            //Comment out this line if not using Google Analytics
            themeEditor.putString(MainActivity.THEME_SAVED, MainActivity.DARKTHEME);
        }
        else{
            themeEditor.putString(MainActivity.THEME_SAVED, MainActivity.LIGHTTHEME);
        }
        themeEditor.apply();

        getActivity().recreate();
    }
}
 
开发者ID:kotlin-korea,项目名称:Minimal-Todo,代码行数:23,代码来源:SettingsFragment.java

示例3: update_nfc_expiry_preferences

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void update_nfc_expiry_preferences(Boolean show_age) {
    try {
        ;
        final PreferenceScreen nfcScreen = (PreferenceScreen) findPreference("xdrip_plus_nfc_settings");
        final String nfc_expiry_days_string = AllPrefsFragment.this.prefs.getString("nfc_expiry_days", "14.5");

        final CheckBoxPreference nfc_show_age = (CheckBoxPreference) findPreference("nfc_show_age");
        nfc_show_age.setSummaryOff("Show the sensor expiry time based on " + nfc_expiry_days_string + " days");
        if (show_age == null) show_age = nfc_show_age.isChecked();
        if (show_age) {
            nfcScreen.removePreference(nfc_expiry_days);
        } else {
            nfc_expiry_days.setOrder(3);
            nfcScreen.addPreference(nfc_expiry_days);
        }
    } catch (NullPointerException e) {
        //
    }
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:20,代码来源:Preferences.java

示例4: onSharedPreferenceChanged

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        PreferenceKeys preferenceKeys = new PreferenceKeys(getResources());
        if(key.equals(preferenceKeys.night_mode_pref_key)){
            SharedPreferences themePreferences = getActivity().getSharedPreferences(MainActivity.THEME_PREFERENCES, Context.MODE_PRIVATE);
            SharedPreferences.Editor themeEditor = themePreferences.edit();
            //We tell our MainLayout to recreate itself because mode has changed
            themeEditor.putBoolean(MainActivity.RECREATE_ACTIVITY, true);

            CheckBoxPreference checkBoxPreference = (CheckBoxPreference)findPreference(preferenceKeys.night_mode_pref_key);
            if(checkBoxPreference.isChecked()){
                //Comment out this line if not using Google Analytics
//                app.send(this, "Settings", "Night Mode used");
                themeEditor.putString(MainActivity.THEME_SAVED, MainActivity.DARKTHEME);
            }
            else{
                themeEditor.putString(MainActivity.THEME_SAVED, MainActivity.LIGHTTHEME);
            }
            themeEditor.apply();

            getActivity().recreate();
        }
    }
 
开发者ID:niuzehai,项目名称:Sxumiro_AndroidClient,代码行数:24,代码来源:SettingsFragment.java

示例5: onPause

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
protected void onPause() {
    super.onPause();
    // Save the selected languages
    String checkedLanguages = "";
    PreferenceGroup parent = getPreferenceScreen();
    int count = parent.getPreferenceCount();
    for (int i = 0; i < count; i++) {
        CheckBoxPreference pref = (CheckBoxPreference) parent.getPreference(i);
        if (pref.isChecked()) {
            Locale locale = mAvailableLanguages.get(i).locale;
            checkedLanguages += get5Code(locale) + ",";
        }
    }
    if (checkedLanguages.length() < 1) checkedLanguages = null; // Save null
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Editor editor = sp.edit();
    editor.putString(LatinIME.PREF_SELECTED_LANGUAGES, checkedLanguages);
    SharedPreferencesCompat.apply(editor);
}
 
开发者ID:klausw,项目名称:hackerskeyboard,代码行数:21,代码来源:InputLanguageSelection.java

示例6: setSummary

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void setSummary(Preference pref, boolean init) {
    if (pref instanceof EditTextPreference) {
        EditTextPreference editPref = (EditTextPreference) pref;
        pref.setSummary(editPref.getText());

        if (editPref.getKey().equals("env_dir") && !init) {
            editPref.setText(PrefStore.getEnvDir(this));
            pref.setSummary(editPref.getText());
        }

        if (editPref.getKey().equals("http_conf") &&
                editPref.getText().isEmpty()) {
            editPref.setText(PrefStore.getHttpConf(this));
            pref.setSummary(editPref.getText());
        }
    }

    if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        pref.setSummary(listPref.getEntry());
    }

    if (pref instanceof CheckBoxPreference) {
        CheckBoxPreference checkPref = (CheckBoxPreference) pref;

        if (checkPref.getKey().equals("logger") && checkPref.isChecked() && init) {
            requestWritePermissions();
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:31,代码来源:SettingsActivity.java

示例7: 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;
			}
		});
}
 
开发者ID:stytooldex,项目名称:stynico,代码行数:30,代码来源:SettingActivity.java

示例8: onPreferenceClick

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
public boolean onPreferenceClick(Preference preference) {

		CheckBoxPreference checkbox = (CheckBoxPreference) preference;
		
		if (checkbox.isChecked()) {
			
			if (hasLightSensor(this)) {
				enableAutobrightness();
			} else {
				// ask user if they really want to use it w/o a light sensor
				checkbox.setChecked(false);
				AlertDialog dialog = new AlertDialog.Builder(this)
					.setIcon(R.drawable.ic_dialog_menu_generic)
					.setTitle(R.string.txt_brightness)
					.setMessage(R.string.msg_enable_autobrightness)
					.setPositiveButton(R.string.btn_yes, this)
					.setNegativeButton(R.string.btn_no, this)
					.create();
				dialog.show();
			}
			
		} else {
			
			// was unchecked
			Setting setting = getApp().getSetting(Setting.BRIGHTNESS);
			setting.enabled = setting.checked = false;
			setting.descr = null;
			setting.removeRenderer();

			int mode = Settings.System.getInt(getContentResolver(), BrightnessSettingHandler.MODE_KEY, BrightnessSettingHandler.MODE_UNSUPPORTED);
	    	if (BrightnessSettingHandler.MODE_AUTO == mode) {
	    		Settings.System.putInt(getContentResolver(), BrightnessSettingHandler.MODE_KEY, BrightnessSettingHandler.MODE_MANUAL);
	    		Toast.makeText(this, R.string.txt_autobrightness_disabled, Toast.LENGTH_SHORT).show();
	    	}			
		}		
		return true;
	}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:38,代码来源:BrightnessPrefs.java

示例9: seleteSex

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void seleteSex(CheckBoxPreference preference) {
    if (preference.isChecked() && !SexUtil.isSelectedSex(getActivity())) {
        SexUtil.selectSex(getActivity(), new SexSelectedListener() {
            @Override
            public void onSelect(boolean select) {
                if (!select) {
                    preference.setChecked(false);
                }
            }
        });
    }
}
 
开发者ID:iQuick,项目名称:NewsMe,代码行数:13,代码来源:SettingFragment.java

示例10: onPreferenceClick

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
    Intent intent = null;
    switch (preference.getKey()) {
        case PreferencesSettings.KEYS.MAIN.ANZ_MOBILE_PAY:
            intent = new Intent(getActivity(), NestedPreferenceActivity.class);
            intent.putExtra("id", R.xml.preferences__anz_mobile_pay);
            intent.putExtra("title", preference.getTitle());
            //intent.putExtra("preference", preference.getKey());
            break;
        case PreferencesSettings.KEYS.MAIN.ANZ_SHIELD:
            intent = new Intent(getActivity(), NestedPreferenceActivity.class);
            intent.putExtra("id", R.xml.preferences__anz_shield);
            intent.putExtra("title", preference.getTitle());
            //intent.putExtra("preference", preference.getKey());
            break;
        case PreferencesSettings.KEYS.MAIN.WESTPAC:
            intent = new Intent(getActivity(), NestedPreferenceActivity.class);
            intent.putExtra("id", R.xml.preferences__westpac);
            intent.putExtra("title", preference.getTitle());
            //intent.putExtra("preference", preference.getKey());
            break;
        case PreferencesSettings.KEYS.MAIN.COMMBANK:
            intent = new Intent(getActivity(), NestedPreferenceActivity.class);
            intent.putExtra("id", R.xml.preferences__commbank);
            intent.putExtra("title", preference.getTitle());
            //intent.putExtra("preference", preference.getKey());
            break;
        case PreferencesSettings.KEYS.MAIN.DEBUG:
            CheckBoxPreference checkBoxPreference = (CheckBoxPreference) preference;
            if(!Common.getInstance().DEBUG) {
                if (checkBoxPreference.isChecked()) {
                    getActivity().setTitle(getResources().getString(R.string.app_name) + " (Debug Mode)");
                } else {
                    getActivity().setTitle(getResources().getString(R.string.app_name));
                }
            }

            SharedPreferences sharedPref = getActivity().getSharedPreferences(Common.getInstance().SHARED_PREFS_FILENAME, Context.MODE_WORLD_READABLE);
            SharedPreferences.Editor sharedPrefEditor = sharedPref.edit();
            sharedPrefEditor.putBoolean(PreferencesSettings.KEYS.MAIN.DEBUG, checkBoxPreference.isChecked());
            sharedPrefEditor.apply();
            return true;
    }
    startActivity(intent);
    getActivity().overridePendingTransition(R.anim.slide_in_from_right, R.anim.slide_out_to_left);
    return true;
}
 
开发者ID:pbombnz,项目名称:KoalaCloak,代码行数:49,代码来源:MainActivity_PreferenceFragment.java

示例11: 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

示例12: onCreate

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

    //init permission listener callback
    setPermissionListener();

    setAnalyticsPermissionListerner();

    //Get Default save location from shared preference
    String defaultSaveLoc = (new File(Environment
            .getExternalStorageDirectory() + File.separator + Const.APPDIR)).getPath();

    //Get instances of all preferences
    prefs = getPreferenceScreen().getSharedPreferences();
    ListPreference res = (ListPreference) findPreference(getString(R.string.res_key));
    ListPreference fps = (ListPreference) findPreference(getString(R.string.fps_key));
    ListPreference bitrate = (ListPreference) findPreference(getString(R.string.bitrate_key));
    recaudio = (CheckBoxPreference) findPreference(getString(R.string.audiorec_key));
    ListPreference filenameFormat = (ListPreference) findPreference(getString(R.string.filename_key));
    EditTextPreference filenamePrefix = (EditTextPreference) findPreference(getString(R.string.fileprefix_key));
    dirChooser = (FolderChooser) findPreference(getString(R.string.savelocation_key));
    floatingControl = (CheckBoxPreference) findPreference(getString(R.string.preference_floating_control_key));
    CheckBoxPreference touchPointer = (CheckBoxPreference) findPreference("touch_pointer");
    crashReporting = (CheckBoxPreference) findPreference(getString(R.string.preference_crash_reporting_key));
    usageStats = (CheckBoxPreference) findPreference(getString(R.string.preference_anonymous_statistics_key));
    //Set previously chosen directory as initial directory
    dirChooser.setCurrentDir(getValue(getString(R.string.savelocation_key), defaultSaveLoc));

    ListPreference theme = (ListPreference) findPreference(getString(R.string.preference_theme_key));
    theme.setSummary(theme.getEntry());

    //Set the summary of preferences dynamically with user choice or default if no user choice is made
    updateResolution(res);
    fps.setSummary(getValue(getString(R.string.fps_key), "30"));
    float bps = bitsToMb(Integer.parseInt(getValue(getString(R.string.bitrate_key), "7130317")));
    bitrate.setSummary(bps + " Mbps");
    dirChooser.setSummary(getValue(getString(R.string.savelocation_key), defaultSaveLoc));
    filenameFormat.setSummary(getFileSaveFormat());
    filenamePrefix.setSummary(getValue(getString(R.string.fileprefix_key), "recording"));

    //If record audio checkbox is checked, check for record audio permission
    if (recaudio.isChecked())
        requestAudioPermission();

    //If floating controls is checked, check for system windows permission
    if (floatingControl.isChecked())
        requestSystemWindowsPermission();

    if(touchPointer.isChecked()){
        if (!hasPluginInstalled())
            touchPointer.setChecked(false);
    }

    //set callback for directory change
    dirChooser.setOnDirectoryClickedListerner(this);
}
 
开发者ID:vijai1996,项目名称:screenrecorder,代码行数:59,代码来源:SettingsPreferenceFragment.java

示例13: onSharedPreferenceChanged

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {
    Preference pref = findPreference(s);
    if (pref == null) return;
    switch (pref.getTitleRes()) {
        case R.string.preference_resolution_title:
            updateResolution((ListPreference) pref);
            break;
        case R.string.preference_fps_title:
            String fps = String.valueOf(getValue(getString(R.string.fps_key), "30"));
            pref.setSummary(fps);
            break;
        case R.string.preference_bit_title:
            float bps = bitsToMb(Integer.parseInt(getValue(getString(R.string.bitrate_key), "7130317")));
            pref.setSummary(bps + " Mbps");
            break;
        case R.string.preference_filename_format_title:
            pref.setSummary(getFileSaveFormat());
            break;
        case R.string.preference_audio_record_title:
            requestAudioPermission();
            break;
        case R.string.preference_filename_prefix_title:
            EditTextPreference etp = (EditTextPreference) pref;
            etp.setSummary(etp.getText());
            ListPreference filename = (ListPreference) findPreference(getString(R.string.filename_key));
            filename.setSummary(getFileSaveFormat());
            break;
        case R.string.preference_floating_control_title:
            requestSystemWindowsPermission();
            break;
        case R.string.preference_show_touch_title:
            CheckBoxPreference showTouchCB = (CheckBoxPreference)pref;
            if (showTouchCB.isChecked() && !hasPluginInstalled()){
                showTouchCB.setChecked(false);
                showDownloadAlert();
            }
            break;
        case R.string.preference_crash_reporting_title:
            CheckBoxPreference crashReporting = (CheckBoxPreference)pref;
            CheckBoxPreference anonymousStats = (CheckBoxPreference) findPreference(getString(R.string.preference_anonymous_statistics_key));
            if(!crashReporting.isChecked())
                anonymousStats.setChecked(false);
            startAnalytics();
            break;
        case R.string.preference_anonymous_statistics_title:
            startAnalytics();
            break;
        case R.string.preference_theme_title:
            activity.recreate();
            break;
    }
}
 
开发者ID:vijai1996,项目名称:screenrecorder,代码行数:54,代码来源:SettingsPreferenceFragment.java


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