Example usage for android.preference PreferenceCategory setTitle

List of usage examples for android.preference PreferenceCategory setTitle

Introduction

In this page you can find the example usage for android.preference PreferenceCategory setTitle.

Prototype

public void setTitle(CharSequence title) 

Source Link

Document

Sets the title for this Preference with a CharSequence.

Usage

From source file:de.azapps.mirakel.settings.custom_views.Settings.java

public static PreferenceScreen inflateHeaders(final @NonNull PreferenceScreen screen,
        final @NonNull OnItemClickedListener<Settings> onClick) {
    for (final Map.Entry<Integer, List<Settings>> id : all.entrySet()) {
        final PreferenceCategory cat = new PreferenceCategory(ctx);
        screen.addPreference(cat);//from  w ww.  j a v  a 2  s .  c om
        cat.setTitle(id.getKey());
        for (final Settings setting : id.getValue()) {
            if (setting == DEV && !MirakelCommonPreferences.isEnabledDebugMenu()) {
                continue;
            }
            cat.addItemFromInflater(setting.getPreference(onClick));
        }
    }
    return screen;

}

From source file:nya.miku.wishmaster.chans.endchan.EndChanModule.java

private void addDomainPreferences(PreferenceGroup group) {
    Context context = group.getContext();
    Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() {
        @Override/*from w w  w . ja  v a  2  s.  com*/
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) {
                updateDomain((String) newValue);
                return true;
            }
            return false;
        }
    };
    PreferenceCategory domainCat = new PreferenceCategory(context);
    domainCat.setTitle(R.string.makaba_prefs_domain_category);
    group.addPreference(domainCat);
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    domainPref.setOnPreferenceChangeListener(updateDomainListener);
    domainCat.addPreference(domainPref);
}

From source file:com.airflo.preferences.ListPreferenceActivity.java

/**
 * Add three slider preferences to a category.
 * @param catTitle// w  w w.ja va 2 s.co m
 * @param key
 * @param no
 */
private void addManyListItems(int catTitle, String key, int no) {
    PreferenceCategory cat = new PreferenceCategory(this);
    cat.setTitle(catTitle);
    root.addPreference(cat);
    String title = getString(R.string.list_pref_hint_selector);
    for (int i = 1; i <= no; i++) {
        String akey = key + i;
        String atitle = title + i;
        addOneListItem(cat, akey, atitle);
    }
}

From source file:com.guipenedo.pokeradar.activities.settings.PokemonFilterSettingsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    getDelegate().installViewFactory();//from   ww w  . java 2s.  co m
    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);
}

From source file:pl.bcichecki.rms.client.android.activities.SettingsActivity.java

@SuppressWarnings("deprecation")
private void setupSimplePreferencesScreen() {
    if (!isSimplePreferences(this)) {
        Log.d(TAG, "Will not create simple preferences.");
        return;/*ww w .j a v  a2 s . c om*/
    }

    Log.d(TAG, "Creating simple preferences.");

    addPreferencesFromResource(R.xml.preferences_dummy);

    PreferenceCategory fakeHeader;

    fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.activity_settings_header_user_account);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.preferences_user_account);

    fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.activity_settings_header_server);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.preferences_server);

    passwordPreference = (EditTextPreference) findPreference(SharedPreferencesWrapper.Keys.USER_PASSWORD_HASH);
    passwordPreference.setOnPreferenceChangeListener(onPassHashPreferenceChangeListener);
    passwordPreference.setOnPreferenceClickListener(onPassHashedPreferenceClickListener);
}

From source file:com.airflo.preferences.ListPreferenceActivity.java

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Override//ww  w .  j  a  va 2s .co  m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    root = getPreferenceManager().createPreferenceScreen(this);

    //Array of sorting preference keys to be included. 
    //SortType must be specified in bookitems.xml!
    String[] sortValues = new String[] { "number", "date;starttime", "site;date;starttime", "duration",
            "maxheight", "maxvario", "starttype;date;starttime" };
    //Generate according Entry Strings.
    String[] sortEntries = new String[sortValues.length];
    for (int i = 0; i < sortEntries.length; i++)
        sortEntries[i] = sortKeyToString(sortValues[i]);

    //Make sorting category
    PreferenceCategory cat = new PreferenceCategory(this);
    cat.setTitle(R.string.list_pref_cat_sort_title);
    root.addPreference(cat);
    final ListPreference listPref = new ListPreference(this);
    listPref.setKey("list_pref_sort");
    listPref.setEntries(sortEntries);
    listPref.setEntryValues(sortValues);
    listPref.setDialogTitle(R.string.list_pref_sort_criterium);
    listPref.setSummary(sortKeyToString(root.getSharedPreferences().getString("list_pref_sort", "number")));
    listPref.setTitle(R.string.list_pref_sort_criterium);
    cat.addPreference(listPref);
    listPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            listPref.setSummary(sortKeyToString((String) newValue));
            return true;
        }
    });
    final ListPreference orderPref = new ListPreference(this);
    orderPref.setKey("list_pref_order");
    orderPref.setEntries(new String[] { OnlyContext.rString("list_pref_sort_ascending"),
            OnlyContext.rString("list_pref_sort_decending") });
    orderPref.setEntryValues(new String[] { "list_pref_sort_ascending", "list_pref_sort_decending" });
    orderPref.setDialogTitle(R.string.list_pref_sort_sequence);
    orderPref.setSummary(OnlyContext
            .rString(root.getSharedPreferences().getString("list_pref_order", "list_pref_sort_decending")));
    orderPref.setTitle(R.string.list_pref_sort_sequence);
    cat.addPreference(orderPref);
    orderPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            orderPref.setSummary(OnlyContext.rString((String) newValue));
            return true;
        }
    });

    //Make item categories
    addManyListItems(R.string.list_pref_cat1_title, "listhead", 3);
    addManyListItems(R.string.list_pref_cat2_title, "listsub", 3);

    this.setPreferenceScreen(root);
}

From source file:io.northernlights.logcleaner.SettingsActivity.java

/**
 * Shows the simplified settings UI if the device configuration if the
 * device configuration dictates that a simplified, single-pane UI should be
 * shown.// w w w  . j a  v  a 2  s.c om
 */
private void setupSimplePreferencesScreen() {
    if (!isSimplePreferences(this)) {
        return;
    }

    // In the simplified UI, fragments are not used at all and we instead
    // use the older PreferenceActivity APIs.

    // Add 'general' preferences.
    addPreferencesFromResource(R.xml.pref_general);

    // Add 'notifications' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_notifications);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_notification);

}

From source file:blackman.matt.Settings.SettingsActivity.java

/**
 * Shows the simplified settings UI if the device configuration if the
 * device configuration dictates that a simplified, single-pane UI should be
 * shown.//from  w  w w.  j  a v a 2s  .  c  o  m
 */
private void setupSimplePreferencesScreen() {
    if (!isSimplePreferences(this)) {
        return;
    }

    // In the simplified UI, fragments are not used at all and we instead
    // use the older PreferenceActivity APIs.

    // Add 'general' preferences.
    addPreferencesFromResource(R.xml.pref_general);

    // Add 'data and sync' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_data_sync);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_data_sync);

    bindPreferenceSummaryToValue(findPreference("default_board"));
    bindPreferenceSummaryToValue(findPreference("sync_frequency"));
}

From source file:com.fhhst.prodroid.gui.SettingsActivity.java

/**
 * Shows the simplified settings UI if the device configuration if the
 * device configuration dictates that a simplified, single-pane UI should be
 * shown.//from   w  w  w. j a v a  2  s . co m
 */
@SuppressWarnings("deprecation")
private void setupSimplePreferencesScreen() {
    if (!isSimplePreferences(this)) {
        return;
    }

    // In the simplified UI, fragments are not used at all and we instead
    // use the older PreferenceActivity APIs.

    // Add 'printer' preferences.

    addPreferencesFromResource(R.xml.pref_printer);
    if (getPreferenceScreen() != null) {

        // Add 'notifications' preferences, and a corresponding header.
        PreferenceCategory fakeHeader1 = new PreferenceCategory(this);
        fakeHeader1.setTitle(R.string.pref_header_communication);
        getPreferenceScreen().addPreference(fakeHeader1);
        addPreferencesFromResource(R.xml.pref_communication);

        // Bind the summaries of EditText/List/Dialog/Ringtone preferences to
        // their values. When their values change, their summaries are updated
        // to reflect the new value, per the Android Design guidelines.
        bindPreferenceSummaryToValue(findPreference("pref_comm_baudrateselect"));
        bindPreferenceSummaryToValue(findPreference("pref_comm_databitsselect"));
        bindPreferenceSummaryToValue(findPreference("pref_comm_stopbitsselect"));
        bindPreferenceSummaryToValue(findPreference("pref_comm_paritybitselect"));
        bindPreferenceSummaryToValue(findPreference("pref_comm_webserver_port"));

        bindPreferenceSummaryToValue(findPreference("pref_print_xyfeedrate"));
        bindPreferenceSummaryToValue(findPreference("pref_print_zfeedrate"));
        bindPreferenceSummaryToValue(findPreference("pref_print_efeedrate"));

        Preference button = (Preference) findPreference("pref_comm_dropbx");
        button.setEnabled(false);

    }

}

From source file:com.nikolak.weatherapp.SettingsActivity.java

/**
 * Shows the simplified settings UI if the device configuration if the
 * device configuration dictates that a simplified, single-pane UI should be
 * shown./*ww w  .  jav  a 2s. co m*/
 */
private void setupSimplePreferencesScreen() {
    if (!isSimplePreferences(this)) {
        return;
    }

    // In the simplified UI, fragments are not used at all and we instead
    // use the older PreferenceActivity APIs.

    // Add 'general' preferences.
    addPreferencesFromResource(R.xml.pref_general);

    // Add 'notifications' preferences, and a corresponding header.
    //        PreferenceCategory fakeHeader = new PreferenceCategory(this);
    //        fakeHeader.setTitle(R.string.pref_header_notifications);
    //        getPreferenceScreen().addPreference(fakeHeader);
    //        addPreferencesFromResource(R.xml.pref_notification);

    // Add 'data and sync' preferences, and a corresponding header.
    PreferenceCategory fakeHeader = new PreferenceCategory(this);
    fakeHeader.setTitle(R.string.pref_header_data_sync);
    getPreferenceScreen().addPreference(fakeHeader);
    addPreferencesFromResource(R.xml.pref_data_sync);

    // Bind the summaries of EditText/List/Dialog/Ringtone preferences to
    // their values. When their values change, their summaries are updated
    // to reflect the new value, per the Android Design guidelines.
    bindPreferenceSummaryToValue(findPreference("custom_location"));
    bindPreferenceSummaryToValue(findPreference("weather_units"));
    bindPreferenceSummaryToValue(findPreference("sync_frequency"));
}