當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。