android.preference.ListPreference#setTitle ( )源码实例Demo

下面列出了android.preference.ListPreference#setTitle ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Overchan-Android   文件: DobroModule.java
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);
}
 
源代码2 项目: haxsync   文件: Preferences.java
@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);
}
 
源代码3 项目: Onosendai   文件: FetchingPrefFragment.java
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);
}
 
@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();
}
 
源代码5 项目: CSipSimple   文件: IiNet.java
@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);
}
 
源代码6 项目: Overchan-Android   文件: SynchModule.java
@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);
}
 
源代码7 项目: JotaTextEditor   文件: SettingsShortcutActivity.java
@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();
}
 
源代码8 项目: Dashchan   文件: BasePreferenceFragment.java
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;
}
 
源代码9 项目: Onosendai   文件: UiPrefFragment.java
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);
}
 
源代码10 项目: Onosendai   文件: UiPrefFragment.java
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);
}
 
源代码11 项目: Onosendai   文件: FetchingPrefFragment.java
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);
}
 
源代码12 项目: Onosendai   文件: FetchingPrefFragment.java
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);
}
 
源代码13 项目: GeoLog   文件: Pref.java
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;
}
 
源代码14 项目: GeoLog   文件: Pref.java
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;
}
 
源代码15 项目: snapdroid   文件: GroupSettingsFragment.java
@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();
    }
 
源代码16 项目: delion   文件: SingleWebsitePreferences.java
/**
 * 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);
}
 
源代码17 项目: AndroidChromium   文件: SingleWebsitePreferences.java
/**
 * 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);
}
 
源代码18 项目: 365browser   文件: SingleWebsitePreferences.java
/**
 * 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);
}
 
源代码19 项目: javainstaller   文件: SettingsActivity.java
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;
   }