本文整理汇总了Java中android.preference.CheckBoxPreference.setSummaryOn方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBoxPreference.setSummaryOn方法的具体用法?Java CheckBoxPreference.setSummaryOn怎么用?Java CheckBoxPreference.setSummaryOn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.preference.CheckBoxPreference
的用法示例。
在下文中一共展示了CheckBoxPreference.setSummaryOn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCheckBox
import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private CheckBoxPreference addCheckBox(String title, PreferenceCategory category, String key, Drawable icon, String onText, String offText, boolean defaultValue, Context context) {
CheckBoxPreference c = new CheckBoxPreference(context);
c.setTitle(title);
c.setKey(key);
if (null != icon) c.setIcon(icon);
if (offText.equals(null) || onText.equals(null)) {
if (offText.equals(null)) {
c.setSummary(onText);
} else if (onText.equals(null)) {
c.setSummary(offText);
}
} else {
c.setSummaryOn(onText);
c.setSummaryOff(offText);
}
c.setDefaultValue(defaultValue);
c.setChecked(KRFAM.sharedPreferences.getBoolean(key, defaultValue));
category.addPreference(c);
return c;
}
示例2: createPreferenceScreen
import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private PreferenceScreen createPreferenceScreen() {
// Root
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
// Units preference
CheckBoxPreference isMetric = new CheckBoxPreference(this);
isMetric.setDefaultValue(PreferenceStore.isMetricLocale());
isMetric.setKey(PreferenceStore.PREFS_METRIC);
isMetric.setTitle(R.string.metric_title);
isMetric.setSummaryOff(R.string.metric_use_english);
isMetric.setSummaryOn(R.string.metric_use_metric);
root.addPreference(isMetric);
// Multitouch preference, aka "pinch zoom"
if (InertiaScroller.isMultitouchAvailable()) {
CheckBoxPreference useMultitouch = new CheckBoxPreference(this);
useMultitouch.setDefaultValue(Boolean.TRUE);
useMultitouch.setKey(PreferenceStore.PREFS_MULTITOUCH);
useMultitouch.setTitle(R.string.multitouch_title);
useMultitouch.setSummaryOff(R.string.multitouch_disable_pinch);
useMultitouch.setSummaryOn(R.string.multitouch_enable_pinch);
root.addPreference(useMultitouch);
}
// Display distance to center of screen
CheckBoxPreference distanceDisplay = new CheckBoxPreference(this);
distanceDisplay.setDefaultValue(false);
distanceDisplay.setKey(PreferenceStore.PREFS_SHOW_DISTANCE);
distanceDisplay.setTitle(R.string.distance_title);
distanceDisplay.setSummaryOn(R.string.distance_show);
distanceDisplay.setSummaryOff(R.string.distance_hide);
root.addPreference(distanceDisplay);
CheckBoxPreference headingDisplay = new CheckBoxPreference(this);
headingDisplay.setDefaultValue(false);
headingDisplay.setKey(PreferenceStore.PREFS_SHOW_HEADING);
headingDisplay.setTitle(R.string.heading_title);
headingDisplay.setSummaryOn(R.string.heading_show);
headingDisplay.setSummaryOff(R.string.heading_hide);
root.addPreference(headingDisplay);
// Display safety reminder when map is changed preference
CheckBoxPreference safetyReminder = new CheckBoxPreference(this);
safetyReminder.setDefaultValue(true);
safetyReminder.setKey(PreferenceStore.PREFS_SHOW_REMINDER);
safetyReminder.setTitle(R.string.safety_reminder_title);
safetyReminder.setSummaryOn(R.string.safety_reminder_show);
safetyReminder.setSummaryOff(R.string.safety_reminder_hide);
root.addPreference(safetyReminder);
// Display language selection option
Preference language = createLanguagePreference();
root.addPreference(language);
// About dialog
Preference about = createAboutPreference();
if (about != null) {
root.addPreference(about);
}
// Maximum image size info
Preference imageSizeInfo = createImageSizeInfo();
if (imageSizeInfo != null) {
root.addPreference(imageSizeInfo);
}
return root;
}
示例3: updateNetworkStats
import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void updateNetworkStats() {
SharedPreferences netStats = getSharedPreferences(NetStatsStorage.NET_STATS_FILE, MODE_PRIVATE);
long totalRcvd = netStats.getLong(NetStatsStorage.NET_STATS_TOTAL_RCVD, 0);
long totalSent = netStats.getLong(NetStatsStorage.NET_STATS_TOTAL_SENT, 0);
mAuxString.setLength(0);
mAuxString.append(getString(R.string.received));
mAuxString.append(": ");
if (totalRcvd/1000000 > 0) {
// More than 1M
double mRcvd = totalRcvd/1000000.0d;
mAuxString.append(String.format("%.1f%s, ", mRcvd, getString(R.string.unitMB)));
}
else if (totalRcvd/1000 > 0) {
// More than 1K
double kRcvd = totalRcvd/1000.0d;
mAuxString.append(String.format("%.1f%s, ", kRcvd, getString(R.string.unitKB)));
}
else {
// Just bytes
mAuxString.append(totalRcvd);
mAuxString.append(String.format("%s, ", getString(R.string.unitB)));
}
mAuxString.append(getString(R.string.sent));
mAuxString.append(": ");
if (totalSent/1000000 > 0) {
// More than 1M
double mSent = totalSent/1000000.0d;
mAuxString.append(String.format("%.1f%s", mSent, getString(R.string.unitMB)));
}
else if (totalSent/1000 > 0) {
// More than 1K
double kSent = totalSent/1000.0d;
mAuxString.append(String.format("%.1f%s", kSent, getString(R.string.unitKB)));
}
else {
mAuxString.append(totalSent);
mAuxString.append(String.format("%s", getString(R.string.unitB)));
}
CheckBoxPreference pref = (CheckBoxPreference)findPreference(PreferenceName.COLLECT_STATS);
pref.setSummaryOn(mAuxString.toString());
}