本文整理汇总了Java中android.preference.Preference.setSummary方法的典型用法代码示例。如果您正苦于以下问题:Java Preference.setSummary方法的具体用法?Java Preference.setSummary怎么用?Java Preference.setSummary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.Preference
的用法示例。
在下文中一共展示了Preference.setSummary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivity().setTitle(R.string.prefs_about_chrome);
addPreferencesFromResource(R.xml.about_chrome_preferences);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
ChromeBasePreference deprecationWarning = new ChromeBasePreference(
new ContextThemeWrapper(getActivity(),
R.style.DeprecationWarningPreferenceTheme));
deprecationWarning.setOrder(-1);
deprecationWarning.setTitle(R.string.deprecation_warning);
deprecationWarning.setIcon(R.drawable.exclamation_triangle);
getPreferenceScreen().addPreference(deprecationWarning);
}
PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance();
AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings();
Preference p = findPreference(PREF_APPLICATION_VERSION);
p.setSummary(getApplicationVersion(getActivity(), versionStrings.getApplicationVersion()));
p = findPreference(PREF_OS_VERSION);
p.setSummary(versionStrings.getOSVersion());
p = findPreference(PREF_LEGAL_INFORMATION);
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
p.setSummary(getString(R.string.legal_information_summary, currentYear));
}
示例2: refreshPreferences
import android.preference.Preference; //导入方法依赖的package包/类
private void refreshPreferences() {
mProfiles.removeAll();
mSingleSettings = SambaConfiguration.getSingleSettingList();
int length = mSingleSettings.size();
Activity activity = getActivity();
for (int index = 0; index < length; index++) {
String section = mSingleSettings.get(index);
SambaSingleSetting sss = SambaConfiguration.getSingleSetting(section);
Preference pref = new Preference(activity);
pref.setTitle(section);
pref.setSummary(sss.getUsername());
pref.setOrder(index);
mProfiles.addPreference(pref);
}
}
示例3: onPreferenceChange
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String value = newValue.toString();
if (isNewAccount) {
builder.setProxy(newValue.toString());
preference.setSummary(newValue.toString());
} else {
mPrefs.setAccountProxy(n, value);
preference.setSummary(mPrefs.getAccountProxy(n));
if (mTransportPreference != null) {
mTransportPreference.setSummary(mPrefs.getAccountTransportString(n));
mTransportPreference.setValue(mPrefs.getAccountTransportKey(n));
}
}
return true;
}
示例4: onPreferenceChange
import android.preference.Preference; //导入方法依赖的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;
}
示例5: onPreferenceChange
import android.preference.Preference; //导入方法依赖的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;
}
示例6: onPreferenceChange
import android.preference.Preference; //导入方法依赖的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;
}
示例7: onPreferenceChange
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String stringValue = newValue.toString();
//only used the first "load". Subsequent changes not because in SeekbarPreferences don't call
//to update listeners
if (preference instanceof SeekBarPreference) {
preference.setSummary(("" + stringValue + " Km"));
} else if (preference instanceof Preference) {
String key = preference.getKey();
//we take the versionName and assign it to the pref var.
if (key == getString(R.string.pref_version_key)) {
String versionName;
try {
versionName = getActivity().getPackageManager().getPackageInfo(
getActivity().getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
versionName = null;
}
preference.setSummary(versionName);
}
}
return true;
}
示例8: startEchoTester
import android.preference.Preference; //导入方法依赖的package包/类
public void startEchoTester() {
Preference preference = findPreference(getString(R.string.pref_echo_tester_key));
try {
if (LinphoneManager.getInstance().startEchoTester() > 0) {
preference.setSummary("Is running");
}
} catch (LinphoneCoreException e) {
e.printStackTrace();
}
}
示例9: onCreate
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preference_about);
Preference version = findPreference(SETTINGS_VERSION);
version.setSummary(getVersion());
}
示例10: setDescriptions
import android.preference.Preference; //导入方法依赖的package包/类
private void setDescriptions(PreferenceScreen screen)
{
for(int i = 0; i < screen.getPreferenceCount(); i++)
{
Preference preference = screen.getPreference(i);
if(preference instanceof EditTextPreference)
preference.setSummary(((EditTextPreference)preference).getText());
if(preference instanceof PreferenceScreen)
setDescriptions((PreferenceScreen)preference);
}
}
示例11: onResume
import android.preference.Preference; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
// update version
Preference preference = findPreference(getString(R.string.preference_key_version));
preference.setSummary(BuildConfig.VERSION_NAME);
}
示例12: onPreferenceChange
import android.preference.Preference; //导入方法依赖的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;
}
示例13: onPreferenceChange
import android.preference.Preference; //导入方法依赖的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;
}
示例14: updateSummary
import android.preference.Preference; //导入方法依赖的package包/类
private void updateSummary(SharedPreferences sharedPreferences, String key) {
Preference updatedPref = settingsFragment.findPreference(key);
// Set summary to be the user-description for the selected value
updatedPref.setSummary(sharedPreferences.getString(key, ""));
}
示例15: onNameUpdate
import android.preference.Preference; //导入方法依赖的package包/类
@OnPrefChange({ R.string.pref_edit_key, R.string.pref_checkbox_key, R.string.pref_switch_key })
void onNameUpdate(Preference preference, Object newValue) {
preference.setSummary(newValue.toString());
}