本文整理汇总了Java中android.support.v7.preference.CheckBoxPreference.setSummary方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBoxPreference.setSummary方法的具体用法?Java CheckBoxPreference.setSummary怎么用?Java CheckBoxPreference.setSummary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.CheckBoxPreference
的用法示例。
在下文中一共展示了CheckBoxPreference.setSummary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateCheckBoxPreference
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
private static boolean updateCheckBoxPreference(
Resources resources,
CheckBoxPreference preference,
int checkedSummaryRes,
int uncheckedSummaryRes) {
final boolean checkboxState = preference.isChecked();
if (checkboxState) {
preference.setSummary(resources.getString(checkedSummaryRes));
} else {
preference.setSummary(resources.getString(uncheckedSummaryRes));
}
return checkboxState;
}
示例2: addAutoSyncProperty
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
protected void addAutoSyncProperty(
final IGISApplication application,
final Account account,
PreferenceGroup syncCategory)
{
final String accountNameHash = "_" + account.name.hashCode();
SharedPreferences sharedPreferences =
mStyledContext.getSharedPreferences(Constants.PREFERENCES,
Constants.MODE_MULTI_PROCESS);
CheckBoxPreference enablePeriodicSync = new CheckBoxPreference(mStyledContext);
enablePeriodicSync.setKey(KEY_SYNC);
enablePeriodicSync.setPersistent(false);
enablePeriodicSync.setTitle(R.string.auto_sync);
boolean isAccountSyncEnabled = isAccountSyncEnabled(account, application.getAuthority());
enablePeriodicSync.setChecked(isAccountSyncEnabled);
enablePeriodicSync.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
{
@Override
public boolean onPreferenceChange(
Preference preference,
Object newValue)
{
boolean isChecked = (boolean) newValue;
setAccountSyncEnabled(account, application.getAuthority(), isChecked);
return true;
}
});
long timeStamp = sharedPreferences.getLong(
com.nextgis.maplib.util.SettingsConstants.KEY_PREF_LAST_SYNC_TIMESTAMP
+ accountNameHash, 0);
if (isAccountSyncEnabled && timeStamp > 0) {
enablePeriodicSync.setSummary(ControlHelper.getSyncTime(mStyledContext, timeStamp));
} else {
enablePeriodicSync.setSummary(R.string.auto_sync_summary);
}
syncCategory.addPreference(enablePeriodicSync);
}