Android Preference - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Preference class.

This code example shows how to use the following methods: setOnPreferenceClickListener, setSummary, Preference.setIcon, Preference.setTitle
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setOnPreferenceChangeListener, setChecked
  public void onResume() { 
    super.onResume(); 
 
    CheckBoxPreference pref=(CheckBoxPreference)findPreference(KEY_ENABLED);
     
    pref.setChecked(mgr.isAdminActive(cn));
    pref.setOnPreferenceChangeListener(this);
  } 
 
  @Override 
  public boolean onPreferenceChange(Preference pref, Object newValue) {
    if (KEY_ENABLED.equals(pref.getKey())) {
      boolean value=((Boolean)newValue).booleanValue();
 
      if (value) {
        Intent intent=
            new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cn);
        intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
                        getString(R.string.device_admin_explanation));
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getContext, getKey, setOnPreferenceChangeListener
	 * @see #sBindPreferenceSummaryToValueListener 
	 */ 
	private static void bindPreferenceSummaryToValue(Preference preference) {
		// Set the listener to watch for value changes. 
		preference
				.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
 
		// Trigger the listener immediately with the preference's 
		// current value. 
		sBindPreferenceSummaryToValueListener.onPreferenceChange(
				preference,
				PreferenceManager.getDefaultSharedPreferences(
						preference.getContext()).getString(preference.getKey(),
						"")); 
	} 
 
	/** 
	 * This fragment shows general preferences only. It is used when the 
	 * activity is showing a two-pane settings UI. 
	 */ 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setEnabled, setChecked
    } 
 
    private void handleNsdStateChanged(int newState) {
        switch (newState) {
            case NsdManager.NSD_STATE_DISABLED:
                mCheckbox.setChecked(false);
                mCheckbox.setEnabled(true);
                break; 
            case NsdManager.NSD_STATE_ENABLED:
                mCheckbox.setChecked(true);
                mCheckbox.setEnabled(true);
                break; 
        } 
    } 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setOnPreferenceClickListener, setSummary, Preference.setIcon, Preference.setTitle
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Preference Questions & Answers:

See Code Examples for Android Preference Methods: