本文整理匯總了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);
}
}