當前位置: 首頁>>代碼示例>>Java>>正文


Java CheckBoxPreference.setSummaryOn方法代碼示例

本文整理匯總了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;
}
 
開發者ID:iebb,項目名稱:Kasumi,代碼行數:21,代碼來源:AppPreferences.java

示例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;
}
 
開發者ID:markoteittinen,項目名稱:custom-maps,代碼行數:69,代碼來源:EditPreferences.java

示例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());
}
 
開發者ID:palo-m,項目名稱:androboinc,代碼行數:44,代碼來源:AppPreferencesActivity.java


注:本文中的android.preference.CheckBoxPreference.setSummaryOn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。