Java Code Examples for android.preference.ListPreference#setTitle()
The following examples show how to use
android.preference.ListPreference#setTitle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FetchingPrefFragment.java From Onosendai with Apache License 2.0 | 6 votes |
private void addBatLevel (final String key, final CharSequence title, final CharSequence defVal, final OnPreferenceChangeListener changeListener) { final ListPreference pref = new ListPreference(getActivity()); pref.setKey(key); pref.setTitle(title); pref.setEntries(CollectionHelper.map(BATTERY_LEVELS, new Function<CharSequence, CharSequence>() { @Override public CharSequence exec (final CharSequence input) { return input + "%"; } }, new ArrayList<CharSequence>()).toArray(new CharSequence[BATTERY_LEVELS.length])); pref.setEntryValues(BATTERY_LEVELS); pref.setSummary("%s"); pref.setDefaultValue(defVal); pref.setOnPreferenceChangeListener(changeListener); getPreferenceScreen().addPreference(pref); }
Example 2
Source File: DobroModule.java From Overchan-Android with GNU General Public License v3.0 | 6 votes |
private void addRatingPreference(PreferenceGroup group) { Context context = group.getContext(); Preference.OnPreferenceChangeListener updateRatingListener = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference.getKey().equals(getSharedKey(PREF_KEY_MAX_RATING))) { setMaxRating((String) newValue); return true; } return false; } }; ListPreference ratingPref = new LazyPreferences.ListPreference(context); ratingPref.setTitle(R.string.dobrochan_prefs_max_rating); ratingPref.setSummary(preferences.getString(getSharedKey(PREF_KEY_MAX_RATING), "R-15")); ratingPref.setEntries(RATINGS); ratingPref.setEntryValues(RATINGS); ratingPref.setDefaultValue("R-15"); ratingPref.setKey(getSharedKey(PREF_KEY_MAX_RATING)); ratingPref.setOnPreferenceChangeListener(updateRatingListener); group.addPreference(ratingPref); }
Example 3
Source File: Preferences.java From haxsync with GNU General Public License v2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Make sure default values are applied. In a real app, you would // want this in a shared function that is used to retrieve the // SharedPreferences wherever they are needed. // PreferenceManager.setDefaultValues(getActivity(), // R.xml.advanced_preferences, false); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.general_prefs); ListPreference listPref = new ListPreference(getActivity()); listPref.setKey("fb_app"); listPref.setOrder(0); NameList apps = IntentUtil.getApps(getActivity()); listPref.setEntries(apps.namesAvail.toArray(new CharSequence[apps.namesAvail.size()])); listPref.setEntryValues(apps.pkgsAvail.toArray(new String[apps.pkgsAvail.size()])); listPref.setTitle(getActivity().getString(R.string.fb_app)); listPref.setSummary(getActivity().getString(R.string.fb_app_description)); getPreferenceScreen().addPreference(listPref); }
Example 4
Source File: BasePreferenceFragment.java From Dashchan with Apache License 2.0 | 5 votes |
public ListPreference makeList(PreferenceGroup parent, String key, CharSequence[] values, String defaultValue, int titleResId, CharSequence[] entries) { ListPreference preference = new ListPreference(getActivity()); preference.setKey(key); preference.setTitle(titleResId); preference.setDialogTitle(titleResId); preference.setEntries(entries); preference.setEntryValues(values); if (defaultValue != null) { preference.setDefaultValue(defaultValue); } addPreference(parent, preference); updateListSummary(preference); return preference; }
Example 5
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static ListPreference List(Context context, PreferenceCategory category, int caption, int summary, int dialogCaption, String key, Object defaultValue, CharSequence[] entries, CharSequence[] entryValues, boolean enabled) { ListPreference retval = new ListPreference(context); if (caption > 0) retval.setTitle(caption); if (summary > 0) retval.setSummary(summary); retval.setEnabled(enabled); retval.setKey(key); retval.setDefaultValue(defaultValue); if (dialogCaption > 0) retval.setDialogTitle(dialogCaption); retval.setEntries(entries); retval.setEntryValues(entryValues); if (category != null) category.addPreference(retval); return retval; }
Example 6
Source File: Pref.java From GeoLog with Apache License 2.0 | 5 votes |
public static ListPreference List(Context context, PreferenceCategory category, String caption, String summary, String dialogCaption, String key, Object defaultValue, CharSequence[] entries, CharSequence[] entryValues, boolean enabled) { ListPreference retval = new ListPreference(context); retval.setTitle(caption); retval.setSummary(summary); retval.setEnabled(enabled); retval.setKey(key); retval.setDefaultValue(defaultValue); retval.setDialogTitle(dialogCaption); retval.setEntries(entries); retval.setEntryValues(entryValues); if (category != null) category.addPreference(retval); return retval; }
Example 7
Source File: FetchingPrefFragment.java From Onosendai with Apache License 2.0 | 5 votes |
private void addPrefetchLinks () { final ListPreference pref = new ListPreference(getActivity()); pref.setKey(KEY_PREFETCH_LINKS); pref.setTitle("Prefetch links"); //ES pref.setSummary("Fetch new link titles during background updates: %s"); //ES pref.setEntries(PrefetchMode.prefEntries()); pref.setEntryValues(PrefetchMode.prefEntryValues()); pref.setDefaultValue(PrefetchMode.NO.getValue()); getPreferenceScreen().addPreference(pref); }
Example 8
Source File: FetchingPrefFragment.java From Onosendai with Apache License 2.0 | 5 votes |
private void addPrefetchMedia () { final ListPreference pref = new ListPreference(getActivity()); pref.setKey(KEY_PREFETCH_MEDIA); pref.setTitle("Prefetch media"); //ES pref.setSummary("Fetch new pictures during background updates: %s"); //ES pref.setEntries(PrefetchMode.prefEntries()); pref.setEntryValues(PrefetchMode.prefEntryValues()); pref.setDefaultValue(PrefetchMode.NO.getValue()); getPreferenceScreen().addPreference(pref); }
Example 9
Source File: UiPrefFragment.java From Onosendai with Apache License 2.0 | 5 votes |
private void addColumnsCount (final String key, final String title) { final ListPreference pref = new ComboPreference(getActivity()); pref.setKey(key); pref.setTitle(title); pref.setEntries(COUNTS); pref.setEntryValues(COUNTS); pref.setDefaultValue(DEFAULT_COUNT); getPreferenceScreen().addPreference(pref); }
Example 10
Source File: UiPrefFragment.java From Onosendai with Apache License 2.0 | 5 votes |
private void addLocalePref () { final ListPreference pref = new ComboPreference(getActivity()); pref.setKey(KEY_LOCALE); pref.setTitle("Locale"); //ES pref.setEntries(SupportedLocales.prefEntries()); pref.setEntryValues(SupportedLocales.prefEntryValues()); pref.setDefaultValue(SupportedLocales.DEFAULT.getValue()); pref.setOnPreferenceChangeListener(this.onLocaleChangeListener); getPreferenceScreen().addPreference(pref); }
Example 11
Source File: SettingsShortcutActivity.java From JotaTextEditor with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPm = getPreferenceManager(); mPs = mPm.createPreferenceScreen(this); setTitle(R.string.label_customize_shortcut); int len = TBL_SUMMARY.length; String[] tbl_summary = new String[ len ]; String[] tbl_function = new String[ len ]; for( int i=0;i<len;i++ ){ tbl_summary[i] = getString(TBL_SUMMARY[i]); tbl_function[i] = Integer.toString(TBL_FUNCTION[i]); } for( DefineShortcut sd : TBL_SHORTCUT ) { final ListPreference pr = new ListPreference(this); pr.setKey(KEY_SHORTCUT + sd.key ); pr.setTitle( sd.name ); pr.setEntries(tbl_summary); pr.setEntryValues(tbl_function); mPs.addPreference(pr); } setPreferenceScreen(mPs); setSummary(); }
Example 12
Source File: SynchModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { Context context = preferenceGroup.getContext(); ListPreference domainPref = new LazyPreferences.ListPreference(context); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.setTitle(R.string.pref_domain); domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT)); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setEntries(DOMAINS); domainPref.setEntryValues(DOMAINS); domainPref.setDefaultValue(DOMAINS[0]); preferenceGroup.addPreference(domainPref); super.addPreferencesOnScreen(preferenceGroup); }
Example 13
Source File: IiNet.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
@Override public void fillLayout(final SipProfile account) { super.fillLayout(account); CharSequence[] states = new CharSequence[] {"act", "nsw", "nt", "qld", "sa", "tas", "vic", "wa"}; accountState = new ListPreference(parent); accountState.setEntries(states); accountState.setEntryValues(states); accountState.setKey("state"); accountState.setDialogTitle(R.string.w_iinet_state); accountState.setTitle(R.string.w_iinet_state); accountState.setSummary(R.string.w_iinet_state_desc); accountState.setDefaultValue("act"); addPreference(accountState); String domain = account.reg_uri; if( domain != null ) { for(CharSequence state : states) { String currentComp = "sip:sip."+state+".iinet.net.au"; if( currentComp.equalsIgnoreCase(domain) ) { accountState.setValue(state.toString()); break; } } } accountUsername.setTitle(R.string.w_iinet_username); accountUsername.setDialogTitle(R.string.w_iinet_username); accountPassword.setTitle(R.string.w_iinet_password); accountPassword.setDialogTitle(R.string.w_iinet_password); }
Example 14
Source File: SettingsShortcutActivity.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPm = getPreferenceManager(); mPs = mPm.createPreferenceScreen(this); setTitle(R.string.label_customize_shortcut); int len = TBL_SUMMARY.length; String[] tbl_summary = new String[ len ]; String[] tbl_function = new String[ len ]; for( int i=0;i<len;i++ ){ tbl_summary[i] = getString(TBL_SUMMARY[i]); tbl_function[i] = Integer.toString(TBL_FUNCTION[i]); } for( DefineShortcut sd : TBL_SHORTCUT ) { final ListPreference pr = new ListPreference(this); pr.setKey(KEY_SHORTCUT + sd.key ); pr.setTitle( sd.name ); pr.setEntries(tbl_summary); pr.setEntryValues(tbl_function); mPs.addPreference(pr); } setPreferenceScreen(mPs); setSummary(); }
Example 15
Source File: GroupSettingsFragment.java From snapdroid with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.group_preferences); PreferenceScreen screen = this.getPreferenceScreen(); prefStreams = (ListPreference) findPreference("pref_stream"); Bundle bundle = getArguments(); try { group = new Group(new JSONObject(bundle.getString("group"))); serverStatus = new ServerStatus(new JSONObject(bundle.getString("serverStatus"))); } catch (JSONException e) { e.printStackTrace(); } final ArrayList<Stream> streams = serverStatus.getStreams(); final CharSequence[] streamNames = new CharSequence[streams.size()]; final CharSequence[] streamIds = new CharSequence[streams.size()]; for (int i = 0; i < streams.size(); ++i) { streamNames[i] = streams.get(i).getName(); streamIds[i] = streams.get(i).getId(); } prefStreams.setEntries(streamNames); prefStreams.setEntryValues(streamIds); for (int i = 0; i < streams.size(); ++i) { if (streamIds[i].equals(group.getStreamId())) { prefStreams.setTitle(streamNames[i]); prefStreams.setValueIndex(i); oldStream = prefStreams.getValue(); break; } } prefStreams.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { for (int i = 0; i < streams.size(); ++i) { if (streamIds[i].equals(newValue)) { prefStreams.setTitle(streamNames[i]); // client.getConfig().setStream(streamIds[i].toString()); prefStreams.setValueIndex(i); break; } } return false; } }); prefCatClients = (PreferenceCategory) findPreference("pref_cat_clients"); ArrayList<CheckBoxPreference> allClients = new ArrayList<>(); for (Group g : serverStatus.getGroups()) { for (Client client : g.getClients()) { CheckBoxPreference checkBoxPref = new CheckBoxPreference(screen.getContext()); checkBoxPref.setKey(client.getId()); checkBoxPref.setTitle(client.getVisibleName()); checkBoxPref.setChecked(g.getId().equals(group.getId())); checkBoxPref.setPersistent(false); allClients.add(checkBoxPref); } } Collections.sort(allClients, new Comparator<CheckBoxPreference>() { @Override public int compare(CheckBoxPreference lhs, CheckBoxPreference rhs) { return lhs.getTitle().toString().compareToIgnoreCase(rhs.getTitle().toString()); } }); for (CheckBoxPreference pref : allClients) prefCatClients.addPreference(pref); oldClients = getClients().toString(); }
Example 16
Source File: SettingsActivity.java From javainstaller with GNU General Public License v3.0 | 4 votes |
private PreferenceScreen createPreferenceHierarchy() { CharSequence[] cs = new String[] { "Terminal Emulator", "Run Activity", "auto" }; CharSequence[] cs2 = new String[] { "off", "on" }; // Root PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this); PreferenceCategory dialogBasedPrefCat = new PreferenceCategory(this); dialogBasedPrefCat.setTitle("install"); root.addPreference(dialogBasedPrefCat); // Adding a category // List preference under the category ListPreference listPref = new ListPreference(this); listPref.setKey("runmode"); listPref.setDefaultValue(cs[2]); listPref.setEntries(cs); listPref.setEntryValues(cs); listPref.setDialogTitle("run install.sh in"); listPref.setTitle("run install.sh in"); listPref.setSummary("run install.sh in"); dialogBasedPrefCat.addPreference(listPref); ListPreference rootmode = new ListPreference(this); rootmode.setKey("rootmode"); rootmode.setDefaultValue(cs2[0]); rootmode.setEntries(cs2); rootmode.setEntryValues(cs2); rootmode.setDialogTitle("run install.sh as superuser"); rootmode.setTitle("run install.sh as superuser"); rootmode.setSummary("root required"); dialogBasedPrefCat.addPreference(rootmode); PreferenceCategory dialogBasedPrefCat2 = new PreferenceCategory(this); dialogBasedPrefCat2.setTitle("run"); root.addPreference(dialogBasedPrefCat2); // Adding a category // List preference under the category CharSequence[] csjar = new String[] { "Terminal Emulator", "Run Activity" }; ListPreference listPref2 = new ListPreference(this); listPref2.setKey("runmode2"); listPref2.setDefaultValue(csjar[1]); listPref2.setEntries(csjar); listPref2.setEntryValues(csjar); listPref2.setDialogTitle("run jar file in"); listPref2.setTitle("run jar file in"); listPref2.setSummary("run jar file in"); dialogBasedPrefCat2.addPreference(listPref2); ListPreference rootmode2 = new ListPreference(this); rootmode2.setKey("rootmode2"); rootmode2.setDefaultValue(cs2[0]); rootmode2.setEntries(cs2); rootmode2.setEntryValues(cs2); rootmode2.setDialogTitle("run jar file as superuser"); rootmode2.setTitle("run jar file as superuser"); rootmode2.setSummary("root required"); dialogBasedPrefCat2.addPreference(rootmode2); PreferenceCategory dialogBasedPrefCat3 = new PreferenceCategory(this); dialogBasedPrefCat3.setTitle("path broadcast"); root.addPreference(dialogBasedPrefCat3); // Adding a category // List preference under the category CharSequence[] cspath = new String[] { "on", "off", "if jamvm is installed" }; ListPreference listPref3 = new ListPreference(this); listPref3.setKey("broadcast"); listPref3.setDefaultValue(cspath[2]); listPref3.setEntries(cspath); listPref3.setEntryValues(cspath); listPref3.setDialogTitle("broadcast path to terminal emulator"); listPref3.setTitle("broadcast path to terminal emulator"); listPref3.setSummary("broadcast path to terminal emulator"); dialogBasedPrefCat3.addPreference(listPref3); EditTextPreference path = new EditTextPreference(this); path.setKey("broadcastpath"); path.setDefaultValue("/data/data/julianwi.javainstaller"); path.setDialogTitle("path to broadcast"); path.setTitle("path to broadcast"); path.setSummary("path to broadcast"); dialogBasedPrefCat3.addPreference(path); return root; }
Example 17
Source File: SingleWebsitePreferences.java From 365browser with Apache License 2.0 | 4 votes |
/** * Initialize a ListPreference with a certain value. * @param preference The ListPreference to initialize. * @param value The value to initialize it to. */ private void setUpListPreference(Preference preference, ContentSetting value) { if (value == null) { getPreferenceScreen().removePreference(preference); return; } ListPreference listPreference = (ListPreference) preference; int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); CharSequence[] keys = new String[2]; CharSequence[] descriptions = new String[2]; keys[0] = ContentSetting.ALLOW.toString(); keys[1] = ContentSetting.BLOCK.toString(); descriptions[0] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW)); descriptions[1] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)); listPreference.setEntryValues(keys); listPreference.setEntries(descriptions); int index = (value == ContentSetting.ALLOW ? 0 : 1); listPreference.setValueIndex(index); int explanationResourceId = ContentSettingsResources.getExplanation(contentType); if (explanationResourceId != 0) { listPreference.setTitle(explanationResourceId); } if (listPreference.isEnabled()) { SiteSettingsCategory category = SiteSettingsCategory.fromContentSettingsType(contentType); if (category != null && !category.enabledInAndroid(getActivity())) { listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity())); listPreference.setEnabled(false); } else { listPreference.setIcon(ContentSettingsResources.getIcon(contentType)); } } else { listPreference.setIcon( ContentSettingsResources.getDisabledIcon(contentType, getResources())); } preference.setSummary("%s"); listPreference.setOnPreferenceChangeListener(this); }
Example 18
Source File: SingleWebsitePreferences.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Initialize a ListPreference with a certain value. * @param preference The ListPreference to initialize. * @param value The value to initialize it to. */ private void setUpListPreference(Preference preference, ContentSetting value) { if (value == null) { getPreferenceScreen().removePreference(preference); return; } ListPreference listPreference = (ListPreference) preference; int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); CharSequence[] keys = new String[2]; CharSequence[] descriptions = new String[2]; keys[0] = ContentSetting.ALLOW.toString(); keys[1] = ContentSetting.BLOCK.toString(); descriptions[0] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW)); descriptions[1] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)); listPreference.setEntryValues(keys); listPreference.setEntries(descriptions); int index = (value == ContentSetting.ALLOW ? 0 : 1); listPreference.setValueIndex(index); int explanationResourceId = ContentSettingsResources.getExplanation(contentType); if (explanationResourceId != 0) { listPreference.setTitle(explanationResourceId); } if (listPreference.isEnabled()) { SiteSettingsCategory category = SiteSettingsCategory.fromContentSettingsType(contentType); if (category != null && !category.enabledInAndroid(getActivity())) { listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity())); listPreference.setEnabled(false); } else { listPreference.setIcon(ContentSettingsResources.getIcon(contentType)); } } else { listPreference.setIcon( ContentSettingsResources.getDisabledIcon(contentType, getResources())); } preference.setSummary("%s"); listPreference.setOnPreferenceChangeListener(this); }
Example 19
Source File: SingleWebsitePreferences.java From delion with Apache License 2.0 | 4 votes |
/** * Initialize a ListPreference with a certain value. * @param preference The ListPreference to initialize. * @param value The value to initialize it to. */ private void setUpListPreference(Preference preference, ContentSetting value) { if (value == null) { getPreferenceScreen().removePreference(preference); return; } ListPreference listPreference = (ListPreference) preference; int contentType = getContentSettingsTypeFromPreferenceKey(preference.getKey()); CharSequence[] keys = new String[2]; CharSequence[] descriptions = new String[2]; keys[0] = ContentSetting.ALLOW.toString(); keys[1] = ContentSetting.BLOCK.toString(); descriptions[0] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.ALLOW)); descriptions[1] = getResources().getString( ContentSettingsResources.getSiteSummary(ContentSetting.BLOCK)); listPreference.setEntryValues(keys); listPreference.setEntries(descriptions); int index = (value == ContentSetting.ALLOW ? 0 : 1); listPreference.setValueIndex(index); int explanationResourceId = ContentSettingsResources.getExplanation(contentType); if (explanationResourceId != 0) { listPreference.setTitle(explanationResourceId); } if (listPreference.isEnabled()) { SiteSettingsCategory category = SiteSettingsCategory.fromContentSettingsType(contentType); if (category != null && !category.enabledInAndroid(getActivity())) { listPreference.setIcon(category.getDisabledInAndroidIcon(getActivity())); listPreference.setEnabled(false); } else { listPreference.setIcon(ContentSettingsResources.getIcon(contentType)); } } else { listPreference.setIcon(getDisabledInChromeIcon(contentType)); } preference.setSummary("%s"); listPreference.setOnPreferenceChangeListener(this); }