本文整理汇总了Java中android.support.v7.preference.CheckBoxPreference.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBoxPreference.setTitle方法的具体用法?Java CheckBoxPreference.setTitle怎么用?Java CheckBoxPreference.setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.preference.CheckBoxPreference
的用法示例。
在下文中一共展示了CheckBoxPreference.setTitle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initSettings
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void initSettings(){
PreferenceScreen screen = getPreferenceScreen();
for(int i = 0; i < courses.size(); i++){
//Add all courses as a checkbox
CheckBoxPreference cbp = new CheckBoxPreference(getContext());
cbp.setPersistent(false);
cbp.setTitle(courses.get(i).getCourseCode());
cbp.setKey("" + courses.get(i).getId());
cbp.setViewId(i);
cbp.setOnPreferenceClickListener(this);
if (courses.get(i).isFavorite()) {
cbp.setChecked(true);
}
checkBoxes.add(cbp);
screen.addPreference(cbp);
}
}
示例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);
}
示例3: populateNewsSources
import android.support.v7.preference.CheckBoxPreference; //导入方法依赖的package包/类
private void populateNewsSources() {
PreferenceCategory newsSourcesPreference = (PreferenceCategory) findPreference("card_news_sources");
NewsManager newsManager = new NewsManager(mContext);
List<NewsSources> newsSources = newsManager.getNewsSources();
final NetUtils net = new NetUtils(mContext);
for (NewsSources newsSource: newsSources) {
final CheckBoxPreference pref = new CheckBoxPreference(mContext);
pref.setKey("card_news_source_" + newsSource.getId());
pref.setDefaultValue(true);
// Load news source icon in background and set it
final String url = newsSource.getIcon();
if (url != null) { // Skip News that do not have a image
new Thread(() -> {
final Optional<Bitmap> bmp = net.downloadImageToBitmap(url);
mContext.runOnUiThread(() -> {
if (bmp.isPresent()) {
pref.setIcon(new BitmapDrawable(getResources(), bmp.get()));
}
});
}).start();
}
pref.setTitle(newsSource.getTitle());
if(newsSourcesPreference!=null) {
newsSourcesPreference.addPreference(pref);
}
}
}