当前位置: 首页>>代码示例>>Java>>正文


Java CheckBoxPreference.setTitle方法代码示例

本文整理汇总了Java中android.preference.CheckBoxPreference.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java CheckBoxPreference.setTitle方法的具体用法?Java CheckBoxPreference.setTitle怎么用?Java CheckBoxPreference.setTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.preference.CheckBoxPreference的用法示例。


在下文中一共展示了CheckBoxPreference.setTitle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());

    PreferenceCategory category = new PreferenceCategory(getActivity());
    category.setTitle("Libraries");

    screen.addPreference(category);

    CheckBoxPreference checkBoxPref = new CheckBoxPreference(getActivity());
    checkBoxPref.setTitle("title");
    checkBoxPref.setSummary("summary");
    checkBoxPref.setChecked(true);

    category.addPreference(checkBoxPref);
    setPreferenceScreen(screen);
}
 
开发者ID:mrspaceman,项目名称:ebookmgr,代码行数:19,代码来源:SettingsActivity.java

示例3: createCheckBoxPreference

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
/**
 * Create a SwitchPreference for the specified preference
 * @param titleResId resource ID to use for the title
 * @param summaryResId resource ID to use for the summary
 * @param key preference key
 * @return newly created preference
 */
private CheckBoxPreference createCheckBoxPreference(@StringRes int titleResId, @StringRes int summaryResId, Settings.Key key) {
    final CheckBoxPreference checkBoxPreference = new CheckBoxPreference(getActivity());
    checkBoxPreference.setDefaultValue(mSettings.getDefault(key));
    checkBoxPreference.setKey(key.name());
    checkBoxPreference.setSummary(summaryResId);
    checkBoxPreference.setTitle(titleResId);
    checkBoxPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            checkBoxPreference.setChecked((boolean) newValue);
            return true;
        }
    });
    return checkBoxPreference;
}
 
开发者ID:nitroshare,项目名称:nitroshare-android,代码行数:23,代码来源:SettingsActivity.java

示例4: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle icicle) {
    // Get the settings preferences
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);

    Design.updateTheme(this, sp);

	super.onCreate(icicle);
    addPreferencesFromResource(R.xml.language_prefs);
    mSelectedLanguages = sp.getString(KP2AKeyboard.PREF_SELECTED_LANGUAGES, "");
    String[] languageList = mSelectedLanguages.split(",");
    
    //first try to get the unique locales in a strict mode (filtering most redundant layouts like English (Jamaica) etc.)
    mAvailableLanguages = getUniqueLocales(true);
    //sometimes the strict check returns only EN_US, EN_GB and ES_US. Accept more in these cases:
    if (mAvailableLanguages.size() < 5)
    {
    	mAvailableLanguages = getUniqueLocales(false);
    }
    PreferenceGroup parent = getPreferenceScreen();
    for (int i = 0; i < mAvailableLanguages.size(); i++) {
        CheckBoxPreference pref = new CheckBoxPreference(this);
        Locale locale = mAvailableLanguages.get(i).locale;
        pref.setTitle(LanguageSwitcher.toTitleCase(locale.getDisplayName(locale), locale));
        boolean checked = isLocaleIn(locale, languageList);
        pref.setChecked(checked);
        if (hasDictionary(locale, this)) {
            pref.setSummary(R.string.has_dictionary);
        }
        parent.addPreference(pref);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:33,代码来源:InputLanguageSelection.java

示例5: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    getDelegate().installViewFactory();
    getDelegate().onCreate(savedInstanceState);
    super.onCreate(savedInstanceState);
    PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(this);
    PreferenceCategory category = new PreferenceCategory(this);
    category.setTitle(R.string.filter_pokemons);
    screen.addPreference(category);
    try {
        JSONArray pokemonList = new JSONArray(Utils.loadJSONFromFile(this, "pokemon.json"));
        for (int i = 0; i < pokemonList.length(); i++){
            JSONObject pokemon = pokemonList.getJSONObject(i);
            CheckBoxPreference checkBox = new CheckBoxPreference(this);
            checkBox.setTitle(pokemon.getString("Name"));
            checkBox.setIcon(new BitmapDrawable(getResources(), Utils.bitmapForPokemon(this, Integer.parseInt(pokemon.getString("Number")))));
            checkBox.setDefaultValue(true);
            checkBox.setSummary(String.format(getString(R.string.setting_filter_pokemon_summary), pokemon.getString("Name")));
            checkBox.setKey("pref_key_show_pokemon_" + Integer.parseInt(pokemon.getString("Number")));
            category.addPreference(checkBox);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

    setPreferenceScreen(screen);
}
 
开发者ID:guipenedo,项目名称:PokeRadar,代码行数:28,代码来源:PokemonFilterSettingsActivity.java

示例6: updateUi

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void updateUi() {
  CheckBoxPreference speedCheckBoxPreference = (CheckBoxPreference) findPreference(
      getString(R.string.chart_show_speed_key));
  speedCheckBoxPreference.setTitle(
      PreferencesUtils.isReportSpeed(this) ? R.string.stats_speed : R.string.stats_pace);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:8,代码来源:ChartSettingsActivity.java

示例7: onCreate

import android.preference.CheckBoxPreference; //导入方法依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.app_selector_screen);

    PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("apps");
    sharedPreferencesPackageNames = getActivity().getSharedPreferences("myPackageNames", MODE_PRIVATE);


    Set<String> all = sharedPreferencesPackageNames.getStringSet(getString(R.string.shared_pref_key_package_name_all), null);
    Set<String> selected = sharedPreferencesPackageNames.getStringSet(getString(R.string.shared_pref_key_package_name_selected), null);

    CheckBoxPreference a = new CheckBoxPreference(getContext());
    a.setKey(getContext().getString(R.string.string_all_key));
    a.setTitle(R.string.string_all_apps);
    if (selected != null){
        if (selected.contains(getContext().getString(R.string.string_all_key))){
            a.setChecked(true);
        }
    }
    a.setOnPreferenceClickListener(this);
    preferenceCategory.addPreference(a);

    if (all != null){
        for(String s: all){
            CheckBoxPreference p = new CheckBoxPreference(getContext());
            p.setKey(s);
            p.setSummary(s);
            p.setEnabled(!a.isChecked());

            if (selected != null){
                if (selected.contains(s)){
                    p.setChecked(true);
                }
            }

            p.setTitle(Utils.getAppName(getContext(), s));
            p.setOnPreferenceClickListener(this);
            preferenceCategory.addPreference(p);
        }
    }

    String title = preferenceCategory.getTitle().toString();

    // all devices with android 8.1 and Pixel 2 (XL) on 8.0 and onward are using "using battery" instead of "running in the background"
    if (Build.VERSION.SDK_INT >= 27 || Build.MODEL.equals("Pixel 2") || Build.MODEL.equals("Pixel 2 XL")){
        title = title.replace("%s", "\"" + getString(R.string.string_app_name_replace_using_battery) + "\"");
    }else{
        title = title.replace("%s", "\"" + getString(R.string.string_app_name_replace_running_in_the_background) + "\"");
    }

    preferenceCategory.setTitle(title);

}
 
开发者ID:iboalali,项目名称:sysnotifsnooze,代码行数:55,代码来源:AppSelectorActivity.java

示例8: 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


注:本文中的android.preference.CheckBoxPreference.setTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。