下面列出了android.preference.CheckBoxPreference#setSummaryOff ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void update_nfc_expiry_preferences(Boolean show_age) {
try {
;
final PreferenceScreen nfcScreen = (PreferenceScreen) findPreference("xdrip_plus_nfc_settings");
final String nfc_expiry_days_string = AllPrefsFragment.this.prefs.getString("nfc_expiry_days", "14.5");
final CheckBoxPreference nfc_show_age = (CheckBoxPreference) findPreference("nfc_show_age");
nfc_show_age.setSummaryOff("Show the sensor expiry time based on " + nfc_expiry_days_string + " days");
if (show_age == null) show_age = nfc_show_age.isChecked();
if (show_age) {
nfcScreen.removePreference(nfc_expiry_days);
} else {
nfc_expiry_days.setOrder(3);
nfcScreen.addPreference(nfc_expiry_days);
}
} catch (NullPointerException e) {
//
}
}
private void update_nfc_expiry_preferences(Boolean show_age) {
try {
;
final PreferenceScreen nfcScreen = (PreferenceScreen) findPreference("xdrip_plus_nfc_settings");
final String nfc_expiry_days_string = AllPrefsFragment.this.prefs.getString("nfc_expiry_days", "14.5");
final CheckBoxPreference nfc_show_age = (CheckBoxPreference) findPreference("nfc_show_age");
nfc_show_age.setSummaryOff("Show the sensor expiry time based on " + nfc_expiry_days_string + " days");
if (show_age == null) show_age = nfc_show_age.isChecked();
if (show_age) {
nfcScreen.removePreference(nfc_expiry_days);
} else {
nfc_expiry_days.setOrder(3);
nfcScreen.addPreference(nfc_expiry_days);
}
} catch (NullPointerException e) {
//
}
}
private void checkGyroSensors() {
//Test the available sensors
SensorManager sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
CheckBoxPreference pref = (CheckBoxPreference) findPreference(KEY_PREF_USE_GYRO_BOOL);
if (sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR) == null && sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) == null) {
pref.setEnabled(false);
pref.setChecked(false);
resetPreference(KEY_PREF_USE_GYRO_BOOL, false);
mNoGyroSensor = true;
pref.setSummaryOff("No gyro or accelerometer sensors found");
Log.i(LOG_TAG, "No gyro or accelerometer sensors found");
} else {
pref.setEnabled(true);
mNoGyroSensor = false;
}
}
private PreferenceScreen createPreferenceHierarchy() {
Log.d(LOGTAG, "createSettingsPreferenceScreen()...");
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager
.setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME);
preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
PreferenceScreen root = preferenceManager.createPreferenceScreen(this);
// PreferenceCategory prefCat = new PreferenceCategory(this);
// // inlinePrefCat.setTitle("");
// root.addPreference(prefCat);
CheckBoxPreference notifyPref = new CheckBoxPreference(this);
notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED);
notifyPref.setTitle(R.string.notifications_enabled);
notifyPref.setSummaryOn(R.string.receive_push_messages);
notifyPref.setSummaryOff(R.string.do_not_receive_push_messages);
notifyPref.setDefaultValue(Boolean.TRUE);
notifyPref
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference,
Object newValue) {
boolean checked = Boolean.valueOf(newValue.toString());
if (checked) {
preference.setTitle(R.string.notifications_enabled);
} else {
preference.setTitle(R.string.notifications_disabled);
}
return true;
}
});
CheckBoxPreference soundPref = new CheckBoxPreference(this);
soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED);
soundPref.setTitle(R.string.sound);
soundPref.setSummary(R.string.play_sound_for_notifications);
soundPref.setDefaultValue(Boolean.TRUE);
// soundPref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED);
CheckBoxPreference vibratePref = new CheckBoxPreference(this);
vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED);
vibratePref.setTitle(R.string.vibrate);
vibratePref.setSummary(R.string.vibrate_the_phone_for_notifications);
vibratePref.setDefaultValue(Boolean.TRUE);
// vibratePref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED);
root.addPreference(notifyPref);
root.addPreference(soundPref);
root.addPreference(vibratePref);
// prefCat.addPreference(notifyPref);
// prefCat.addPreference(soundPref);
// prefCat.addPreference(vibratePref);
// root.addPreference(prefCat);
return root;
}
private PreferenceScreen createPreferenceHierarchy() {
Log.d(LOGTAG, "createSettingsPreferenceScreen()...");
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager
.setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME);
preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
PreferenceScreen root = preferenceManager.createPreferenceScreen(this);
CheckBoxPreference notifyPref = new CheckBoxPreference(this);
notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED);
notifyPref.setTitle("Notifications Enabled");
notifyPref.setSummaryOn("Receive push messages");
notifyPref.setSummaryOff("Do not receive push messages");
notifyPref.setDefaultValue(Boolean.TRUE);
notifyPref
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference,
Object newValue) {
boolean checked = Boolean.valueOf(newValue.toString());
if (checked) {
preference.setTitle("Notifications Enabled");
} else {
preference.setTitle("Notifications Disabled");
}
return true;
}
});
CheckBoxPreference soundPref = new CheckBoxPreference(this);
soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED);
soundPref.setTitle("Sound");
soundPref.setSummary("Play a sound for notifications");
soundPref.setDefaultValue(Boolean.TRUE);
CheckBoxPreference vibratePref = new CheckBoxPreference(this);
vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED);
vibratePref.setTitle("Vibrate");
vibratePref.setSummary("Vibrate the phone for notifications");
vibratePref.setDefaultValue(Boolean.TRUE);
root.addPreference(notifyPref);
root.addPreference(soundPref);
root.addPreference(vibratePref);
return root;
}
private PreferenceScreen createPreferenceHierarchy() {
Log.d(LOGTAG, "createSettingsPreferenceScreen()...");
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager
.setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME);
preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);
PreferenceScreen root = preferenceManager.createPreferenceScreen(this);
// PreferenceCategory prefCat = new PreferenceCategory(this);
// // inlinePrefCat.setTitle("");
// root.addPreference(prefCat);
CheckBoxPreference notifyPref = new CheckBoxPreference(this);
notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED);
notifyPref.setTitle("Notifications Enabled");
notifyPref.setSummaryOn("Receive push messages");
notifyPref.setSummaryOff("Do not receive push messages");
notifyPref.setDefaultValue(Boolean.TRUE);
notifyPref
.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference,
Object newValue) {
boolean checked = Boolean.valueOf(newValue.toString());
if (checked) {
preference.setTitle("Notifications Enabled");
} else {
preference.setTitle("Notifications Disabled");
}
return true;
}
});
CheckBoxPreference soundPref = new CheckBoxPreference(this);
soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED);
soundPref.setTitle("Sound");
soundPref.setSummary("Play a sound for notifications");
soundPref.setDefaultValue(Boolean.TRUE);
// soundPref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED);
CheckBoxPreference vibratePref = new CheckBoxPreference(this);
vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED);
vibratePref.setTitle("Vibrate");
vibratePref.setSummary("Vibrate the phone for notifications");
vibratePref.setDefaultValue(Boolean.TRUE);
// vibratePref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED);
root.addPreference(notifyPref);
root.addPreference(soundPref);
root.addPreference(vibratePref);
// prefCat.addPreference(notifyPref);
// prefCat.addPreference(soundPref);
// prefCat.addPreference(vibratePref);
// root.addPreference(prefCat);
return root;
}