本文整理汇总了Java中android.support.v7.preference.Preference.setSummary方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.setSummary方法的具体用法?Java Preference.setSummary怎么用?Java Preference.setSummary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.Preference
的用法示例。
在下文中一共展示了Preference.setSummary方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPreferenceSummary
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
private void setPreferenceSummary(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 (since they have separate labels/values).
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(stringValue);
if (prefIndex >= 0) {
preference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else {
// For other preferences, set the summary to the value's simple string representation.
preference.setSummary(stringValue);
}
}
示例2: setPreferenceSummary
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
private void setPreferenceSummary(Preference preference, Object value) {
String stringValue = value.toString();
String key = preference.getKey();
if (preference instanceof ListPreference) {
/* For list preferences, look up the correct display value in */
/* the preference's 'entries' list (since they have separate labels/values). */
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(stringValue);
if (prefIndex >= 0) {
preference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else {
// For other preferences, set the summary to the value's simple string representation.
preference.setSummary(stringValue);
}
}
示例3: setPreferenceSummary
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
/**
* Updates the summary for the preference
*
* @param preference The preference to be updated
* @param value The value that the preference was updated to
*/
private void setPreferenceSummary(Preference preference, String value) {
if (preference instanceof ListPreference) {
// For list preferences, figure out the label of the selected value
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(value);
if (prefIndex >= 0) {
// Set the summary to that label
listPreference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else if (preference instanceof EditTextPreference) {
if (preference.getKey().equals(getString(R.string.pref_radius_key))) {
preference.setSummary(value + "m");
} else {
// For EditTextPreferences, set the summary to the value's simple string representation.
preference.setSummary(value);
}
}
}
示例4: updateDownloadSummary
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
private void updateDownloadSummary(Preference update) {
update.setSummary(getString(R.string.settings_update_summary));
String date = StorageUtils.getStringPref(getActivity(), getString(R.string.license_last_updated_key));
if (!date.equals("")) {
update.setSummary(update.getSummary()+" "+getString(R.string.settings_update_summary_extra)+" "+date);
}
}
示例5: onViewCreated
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
app = (App) getContext().getApplicationContext();
setYearAdapters();
view.setBackgroundColor(Color.parseColor("#FFFFFF"));
Preference preference = findPreference("preference_logout");
preference.setOnPreferenceClickListener(onLogout);
Preference year = findPreference("preference_staticyear");
year.setOnPreferenceClickListener(onStaticYear);
Preference test = findPreference("preference_notification");
test.setOnPreferenceClickListener(onNotificationsOpen);
Preference about = findPreference("preference_about");
about.setOnPreferenceClickListener(onAbout);
Preference shortcut = findPreference("preference_shortcut");
shortcut.setOnPreferenceClickListener(onTheme);
Preference shortcut1 = findPreference("preference_webmail");
shortcut1.setOnPreferenceClickListener(onTheme1);
Preference tys = findPreference("preference_tys");
tys.setOnPreferenceClickListener(onTySRequest);
String type = "release";
if (AppManager.isDebug())
type = "debug";
Preference version = findPreference("preference_version");
version.setTitle("ConnectU App version " + AppManager.getAppVersion(getContext()));
version.setSummary("You are on " + type + " mode");
}
示例6: onPreferenceChange
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
Log.d("SettingsActivity", "onPreferenceChange() called with: preference = [" + preference + "], o = [" + o + "]");
if (callback != null) {
callback.onSettingChanged();
}
Settings settings = Settings.getInstance(getActivity());
if (preference.getKey().equals(getString(R.string.pref_key_theme))) {
String themeValue = (String) o;
settings.setTheme(themeValue);
String theme_name = Settings.Utils.getThemeName(getActivity(), themeValue);
preference.setSummary(theme_name);
//update Activities
getActivity().recreate();
} else if (preference.getKey().equals(getString(R.string.pref_key_style))) {
settings.setStyle((int) o);
String style_name = Settings.Utils.getStyleName(getActivity(), (int) o);
preference.setSummary(style_name);
} else if (preference.getKey().equals(getString(R.string.pref_key_column_count))) {
settings.setColumnCount((int) o);
preference.setSummary(String.valueOf(o));
} else if (preference.getKey().equals(getString(R.string.pref_key_media_retriever))) {
settings.useStorageRetriever((boolean) o);
} else if (preference.getKey().equals(getString(R.string.pref_key_8_bit_color))) {
settings.use8BitColor((boolean) o);
} else if (preference.getKey().equals(getString(R.string.pref_key_camera_shortcut))) {
settings.setCameraShortcut((boolean) o);
}
return true;
}
示例7: onUserGet
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
@Override
public void onUserGet(TraktGson.TraktUser user, Drawable icon) {
Preference pref = findPreference(getString(R.string.pref_key_login));
if(pref != null && user != null) {
pref.setTitle("Logged in as: " + user.username);
pref.setSummary("Click for re-outh");
if(icon != null) {
pref.setIcon(icon);
}
}
}
示例8: setPreferenceSummary
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
/**
* Updates the summary for the preference
*
* @param preference The preference to be updated
* @param value The value that the preference was updated to
*/
private void setPreferenceSummary(Preference preference, String value) {
if (preference instanceof ListPreference) {
// For list preferences, figure out the label of the selected value
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(value);
if (prefIndex >= 0) {
// Set the summary to that label
listPreference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else if (preference instanceof EditTextPreference) {
// For EditTextPreferences, set the summary to the value's simple string representation.
preference.setSummary(value);
}
}
示例9: setPreferenceSummary
import android.support.v7.preference.Preference; //导入方法依赖的package包/类
/**
* Updates the summary for the preference
*
* @param preference The preference to be updated
* @param value The value that the preference was updated to
*/
private void setPreferenceSummary(Preference preference, String value) {
// COMPLETED (3) Don't forget to add code here to properly set the summary for an EditTextPreference
if (preference instanceof ListPreference) {
// For list preferences, figure out the label of the selected value
ListPreference listPreference = (ListPreference) preference;
int prefIndex = listPreference.findIndexOfValue(value);
if (prefIndex >= 0) {
// Set the summary to that label
listPreference.setSummary(listPreference.getEntries()[prefIndex]);
}
} else if (preference instanceof EditTextPreference) {
preference.setSummary(value);
}
}