Code example for PreferenceCategory

Methods: setTitleaddPreference

0
		DigitsKeyListener decimal = new DigitsKeyListener(false, true);
 
		PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
 
		// general prefs 
		PreferenceCategory generalPrefs = new PreferenceCategory(this);
		generalPrefs.setTitle("General");
		root.addPreference(generalPrefs);
		// ListPreference defaultGroup = new ListPreference(this); 
		// Decimal places 
		EditTextPreference decimalPlaces = new EditTextPreference(this);
		decimalPlaces.setDialogTitle("Number of Decimal Places");
		decimalPlaces.setKey(PREFS_DECIMAL_PLACES);
		decimalPlaces.setTitle("Decimal Places");
		decimalPlaces.setSummary("The number of decimal places to round to");
		decimalPlaces.setDefaultValue(new Integer(PREFS_DECIMAL_PLACES_DEFAULT).toString());
		decimalPlaces.getEditText().setKeyListener(integer);
		generalPrefs.addPreference(decimalPlaces);
 
		CheckBoxPreference runStartup = new CheckBoxPreference(this);
		runStartup.setKey(PREFS_STARTUP_ENABLED);
		runStartup.setTitle("Run at Start-up");
		runStartup.setSummary("Enable/Disable ContextProvider Start at System Boot");
		runStartup.setDefaultValue(new Boolean(PREFS_STARTUP_ENABLED_DEFAULT));
		generalPrefs.addPreference(runStartup);
 
		CheckBoxPreference shakeEnabled = new CheckBoxPreference(this);
		shakeEnabled.setKey(PREFS_SHAKE_ENABLED);
		shakeEnabled.setTitle("Shake Response");
		shakeEnabled.setSummary("Enable/Disable ContextProvider Instant-Context on Shake");
		shakeEnabled.setDefaultValue(new Boolean(PREFS_SHAKE_ENABLED_DEFAULT));
		generalPrefs.addPreference(shakeEnabled);
 
		CheckBoxPreference ttsEnabled = new CheckBoxPreference(this);
		ttsEnabled.setKey(PREFS_TTS_ENABLED);
		ttsEnabled.setTitle("TTS Context");
		ttsEnabled.setSummary("Enable/Disable ContextProvider Context Speaking");
		ttsEnabled.setDefaultValue(new Boolean(PREFS_TTS_ENABLED_DEFAULT));
		generalPrefs.addPreference(ttsEnabled);
 
		// location prefs 
		PreferenceCategory locationPrefs = new PreferenceCategory(this);
		locationPrefs.setTitle("Location Parameters");
		root.addPreference(locationPrefs);