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


Java ListPreference类代码示例

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


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

示例1: onCreate

import android.preference.ListPreference; //导入依赖的package包/类
/**
 * Set the default preference values.
 *
 * @param savedInstanceState the current Activity's state, as passed by
 *            Android
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.preferences);
  
  sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
  
  listPreferenceSourceLanguage = (ListPreference) getPreferenceScreen().findPreference(KEY_SOURCE_LANGUAGE_PREFERENCE);
  listPreferenceTargetLanguage = (ListPreference) getPreferenceScreen().findPreference(KEY_TARGET_LANGUAGE_PREFERENCE);
  listPreferenceTranslator = (ListPreference) getPreferenceScreen().findPreference(KEY_TRANSLATOR);    
  listPreferenceOcrEngineMode = (ListPreference) getPreferenceScreen().findPreference(KEY_OCR_ENGINE_MODE);
  editTextPreferenceCharacterBlacklist = (EditTextPreference) getPreferenceScreen().findPreference(KEY_CHARACTER_BLACKLIST);
  editTextPreferenceCharacterWhitelist = (EditTextPreference) getPreferenceScreen().findPreference(KEY_CHARACTER_WHITELIST);
  listPreferencePageSegmentationMode = (ListPreference) getPreferenceScreen().findPreference(KEY_PAGE_SEGMENTATION_MODE);
  
  // Create the entries/entryvalues for the translation target language list.
  initTranslationTargetList();
  
}
 
开发者ID:mercuriete,项目名称:android-mrz-reader,代码行数:26,代码来源:PreferencesActivity.java

示例2: onPreExecute

import android.preference.ListPreference; //导入依赖的package包/类
@Override
protected void onPreExecute() {
    autoExpandFolder = (ListPreference) findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
    autoExpandFolder.setEnabled(false);
    archiveFolder = (ListPreference) findPreference(PREFERENCE_ARCHIVE_FOLDER);
    archiveFolder.setEnabled(false);
    draftsFolder = (ListPreference) findPreference(PREFERENCE_DRAFTS_FOLDER);
    draftsFolder.setEnabled(false);
    sentFolder = (ListPreference) findPreference(PREFERENCE_SENT_FOLDER);
    sentFolder.setEnabled(false);
    spamFolder = (ListPreference) findPreference(PREFERENCE_SPAM_FOLDER);
    spamFolder.setEnabled(false);
    trashFolder = (ListPreference) findPreference(PREFERENCE_TRASH_FOLDER);
    trashFolder.setEnabled(false);

    if (!isMoveCapable) {
        PreferenceScreen foldersCategory =
                (PreferenceScreen) findPreference(PREFERENCE_CATEGORY_FOLDERS);
        foldersCategory.removePreference(archiveFolder);
        foldersCategory.removePreference(spamFolder);
        foldersCategory.removePreference(draftsFolder);
        foldersCategory.removePreference(sentFolder);
        foldersCategory.removePreference(trashFolder);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:26,代码来源:AccountSettings.java

示例3: onCreate

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState)
{
	super.onCreate(savedInstanceState);

	// inflate
	addPreferencesFromResource(R.xml.pref_service);

	// preference
	final ListPreference listPreference = (ListPreference) findPreference(Settings.PREF_SERVICE);

	// activity
	final SettingsActivity activity = (SettingsActivity) getActivity();

	// connect to data
	activity.fillWithServiceData(listPreference);

	// bind
	activity.bind(listPreference, Settings.getStringPref(activity, listPreference.getKey()), activity.listener);
}
 
开发者ID:1313ou,项目名称:Treebolic,代码行数:21,代码来源:SettingsActivity.java

示例4: onCreate

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  addPreferencesFromResource(R.xml.preferences_chats);

  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_MOBILE_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_WIFI_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MEDIA_DOWNLOAD_ROAMING_PREF)
      .setOnPreferenceChangeListener(new MediaDownloadChangeListener());
  findPreference(TextSecurePreferences.MESSAGE_BODY_TEXT_SIZE_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());

  findPreference(TextSecurePreferences.THREAD_TRIM_NOW)
      .setOnPreferenceClickListener(new TrimNowClickListener());
  findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH)
      .setOnPreferenceChangeListener(new TrimLengthValidationListener());

  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.MESSAGE_BODY_TEXT_SIZE_PREF));
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:22,代码来源:ChatsPreferenceFragment.java

示例5: onPreferenceChange

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
	String stringValue = value.toString();

	if (preference instanceof ListPreference) {
		// For list preferences, look up the correct display value in
		// the preference's 'entries' list.
		ListPreference listPreference = (ListPreference) preference;
		int index = listPreference.findIndexOfValue(stringValue);

		// Set the summary to reflect the new value.
		preference.setSummary(
				index >= 0
						? listPreference.getEntries()[index]
						: null);
	} else {
		// For all other preferences, set the summary to the value's
		// simple string representation.
		preference.setSummary(stringValue);
	}
	return true;
}
 
开发者ID:ScreamingHawk,项目名称:android-slideshow,代码行数:23,代码来源:SettingsActivity.java

示例6: onCreate

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public void onCreate(Bundle paramBundle) {
  super.onCreate(paramBundle);
  masterSecret = getArguments().getParcelable("master_secret");
  addPreferencesFromResource(R.xml.preferences_notifications);

  this.findPreference(TextSecurePreferences.LED_COLOR_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.LED_BLINK_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.RINGTONE_PREF)
      .setOnPreferenceChangeListener(new RingtoneSummaryListener());
  this.findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF)
      .setOnPreferenceChangeListener(new ListSummaryListener());
  this.findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF)
      .setOnPreferenceChangeListener(new NotificationPrivacyListener());

  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_COLOR_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.LED_BLINK_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.REPEAT_ALERTS_PREF));
  initializeListSummary((ListPreference) findPreference(TextSecurePreferences.NOTIFICATION_PRIVACY_PREF));
  initializeRingtoneSummary((RingtonePreference) findPreference(TextSecurePreferences.RINGTONE_PREF));
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:24,代码来源:NotificationsPreferenceFragment.java

示例7: fillWithServiceData

import android.preference.ListPreference; //导入依赖的package包/类
/**
 * Connect list preference to service data
 *
 * @param listPreference list preference
 */
private void fillWithServiceData(@NonNull final ListPreference listPreference)
{
	final List<HashMap<String, Object>> services = Services.getServices(this, true);
	if (services != null)
	{
		final int n = services.size();
		final String[] entries = new String[n];
		final String[] values = new String[n];
		for (int i = 0; i < n; i++)
		{
			final HashMap<String, Object> service = services.get(i);
			entries[i] = (String) service.get(Services.LABEL);
			values[i] = (String) service.get(Services.PACKAGE) + '/' + service.get(Services.NAME);
		}
		listPreference.setEntries(entries);
		listPreference.setEntryValues(values);
	}
}
 
开发者ID:1313ou,项目名称:Treebolic,代码行数:24,代码来源:SettingsActivity.java

示例8: onPreferenceChange

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
开发者ID:bjaanes,项目名称:BeaconMqtt,代码行数:23,代码来源:SettingsActivity.java

示例9: onPreferenceChange

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
开发者ID:mmlevin,项目名称:C500Companion,代码行数:24,代码来源:SettingsActivity.java

示例10: onPreferenceChange

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else if (preference instanceof RingtonePreference) {
    } else if (preference instanceof EditTextPreference) {
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:25,代码来源:PreferencesUtil.java

示例11: setKeys

import android.preference.ListPreference; //导入依赖的package包/类
private void setKeys(PreferenceScreen screen)
{
	for(int i = 0; i < screen.getPreferenceCount(); i++)
	{
		Preference preference = screen.getPreference(i);
		String key = server + ";" + preference.getKey();
		preference.setKey(key);
		if(preference instanceof EditIntPreference)
			((EditIntPreference)preference).setInt(preference.getSharedPreferences().getInt(key, -1));
		else if(preference instanceof EditTextPreference)
			((EditTextPreference)preference).setText(preference.getSharedPreferences().getString(key, null));
		else if(preference instanceof ListPreference)
			((ListPreference)preference).setValue(preference.getSharedPreferences().getString(key, null));
		else if(preference instanceof CheckBoxPreference)
			((CheckBoxPreference)preference).setChecked(preference.getSharedPreferences().getBoolean(key, false));
		if(preference instanceof PreferenceScreen)
			setKeys((PreferenceScreen)preference);
	}
}
 
开发者ID:mniip,项目名称:bananapeel,代码行数:20,代码来源:ServerPreferencesScreen.java

示例12: onPreferenceChange

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);

    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
开发者ID:cache117,项目名称:social-journal,代码行数:21,代码来源:SettingsActivity.java

示例13: setPreferenceSummaryByValue

import android.preference.ListPreference; //导入依赖的package包/类
/**
 * Sets the summary of the preference according to its value
 *
 * @param preference
 * @param value
 */
private static void setPreferenceSummaryByValue(Preference preference, Object value) {
    String stringValue = value.toString();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list.
        ListPreference listPreference = (ListPreference) preference;
        int index = listPreference.findIndexOfValue(stringValue);

        // Set the summary to reflect the new value.
        preference.setSummary(
                index >= 0
                        ? listPreference.getEntries()[index]
                        : null);
    }
    else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
}
 
开发者ID:mkeresztes,项目名称:AndiCar,代码行数:28,代码来源:PreferenceActivity.java

示例14: onPreferenceChange

import android.preference.ListPreference; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();
    if (preference instanceof ListPreference) {
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            CharSequence[] labels  = listPreference.getEntries();
            preference.setSummary(labels[prefIndex]);
        }

    }else {
        preference.setSummary(stringValue);
    }
    return true;
}
 
开发者ID:wenzhifeifeidetutu,项目名称:QuakeRepor,代码行数:17,代码来源:SettingActivity.java

示例15: onCreate

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

    // This sample app uses shared preferences to maintain app restriction settings.  Your app
    // can use other methods to maintain the settings.
    mBooleanPref = (CheckBoxPreference) findPreference(KEY_BOOLEAN_PREF);
    mChoicePref = (ListPreference) findPreference(KEY_CHOICE_PREF);
    mMultiPref = (MultiSelectListPreference) findPreference(KEY_MULTI_PREF);

    mBooleanPref.setOnPreferenceChangeListener(this);
    mChoicePref.setOnPreferenceChangeListener(this);
    mMultiPref.setOnPreferenceChangeListener(this);

    setRetainInstance(true);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:18,代码来源:CustomRestrictionsFragment.java


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