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


Java ListPreference.findIndexOfValue方法代码示例

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


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

示例1: 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:ekumenlabs,项目名称:tangobot,代码行数:20,代码来源:MasterChooserSettingsActivity.java

示例2: 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:dandanes7,项目名称:lurkerhn,代码行数:23,代码来源:SettingsActivity.java

示例3: 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

示例4: 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

示例5: onPreferenceChange

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.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:gincos,项目名称:BeHealthy,代码行数:16,代码来源:SettingsActivity.java

示例6: updateListPreferenceSummaryToCurrentValue

import android.preference.ListPreference; //导入方法依赖的package包/类
static void updateListPreferenceSummaryToCurrentValue(final String prefKey,
        final PreferenceScreen screen) {
    // Because the "%s" summary trick of {@link ListPreference} doesn't work properly before
    // KitKat, we need to update the summary programmatically.
    final ListPreference listPreference = (ListPreference)screen.findPreference(prefKey);
    if (listPreference == null) {
        return;
    }
    final CharSequence entries[] = listPreference.getEntries();
    final int entryIndex = listPreference.findIndexOfValue(listPreference.getValue());
    listPreference.setSummary(entryIndex < 0 ? null : entries[entryIndex]);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:13,代码来源:SubScreenFragment.java

示例7: 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:ECFK75C8,项目名称:Lagos-Developers-App,代码行数:16,代码来源:Settings.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 if (preference instanceof RingtonePreference) {
        // For ringtone preferences, look up the correct display value
        // using RingtoneManager.
        if (TextUtils.isEmpty(stringValue)) {
            // Empty values correspond to 'silent' (no ringtone).
            preference.setSummary(R.string.pref_ringtone_silent);

        } else {
            Ringtone ringtone = RingtoneManager.getRingtone(
                    preference.getContext(), Uri.parse(stringValue));

            if (ringtone == null) {
                // Clear the summary if there was a lookup error.
                preference.setSummary(null);
            } else {
                // Set the summary to reflect the new ringtone display
                // name.
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
            }
        }

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

示例9: onPreferenceChange

import android.preference.ListPreference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString ();
    //Log.d (TAG, "onPreferenceChange: Preference name = "+PreferenceManager.getDefaultSharedPreferencesName (preference.getContext ()));
    if (DEBUG)
        Log.d (TAG, "onPreferenceChange: preference = " + preference + " stringValue = " + stringValue);
    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) {
        // For ringtone preferences, look up the correct display value
        // using RingtoneManager.
        if (TextUtils.isEmpty (stringValue)) {
            // Empty values correspond to 'silent' (no ringtone).
            preference.setSummary (R.string.pref_ringtone_silent);

        } else {
            Ringtone ringtone = RingtoneManager.getRingtone (
                    preference.getContext (), Uri.parse (stringValue));

            if (ringtone == null) {
                // Clear the summary if there was a lookup error.
                preference.setSummary (null);
            } else {
                // Set the summary to reflect the new ringtone display
                // name.
                String name = ringtone.getTitle (preference.getContext ());
                preference.setSummary (name);
            }
        }

    } else if (preference instanceof EditTextPreference) {
        preference.setSummary (stringValue);
    }
    return true;
}
 
开发者ID:atulgpt,项目名称:TimeTrix,代码行数:46,代码来源:SettingsPreferenceActivity.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) {
    // For ringtone preferences, look up the correct display value
    // using RingtoneManager.
    if (TextUtils.isEmpty(stringValue)) {
      // Empty values correspond to 'silent' (no ringtone).
      preference.setSummary(R.string.pref_ringtone_silent);

    } else {
      Ringtone ringtone = RingtoneManager.getRingtone(
        preference.getContext(), Uri.parse(stringValue));

      if (ringtone == null) {
        // Clear the summary if there was a lookup error.
        preference.setSummary(null);
      } else {
        // Set the summary to reflect the new ringtone display
        // name.
        String name = ringtone.getTitle(preference.getContext());
        preference.setSummary(name);
      }
    }

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

示例11: 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 SwitchPreference) {
        // For a boolean value, set the default value "true"
        preference.setDefaultValue((stringValue.contains("t")));
    } else {
        // For all other preferences, set the summary to the value's
        // simple string representation.
        preference.setSummary(stringValue);
    }
    return true;
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:24,代码来源:SettingsActivity.java


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