Example usage for android.preference CheckBoxPreference getKey

List of usage examples for android.preference CheckBoxPreference getKey

Introduction

In this page you can find the example usage for android.preference CheckBoxPreference getKey.

Prototype

public String getKey() 

Source Link

Document

Gets the key for this Preference, which is also the key used for storing values into SharedPreferences or PreferenceDataStore .

Usage

From source file:Main.java

static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
        final PreferenceGroup group) {
    final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
    switchPref.setTitle(checkBox.getTitle());
    switchPref.setKey(checkBox.getKey());
    switchPref.setOrder(checkBox.getOrder());
    switchPref.setPersistent(checkBox.isPersistent());
    switchPref.setEnabled(checkBox.isEnabled());
    switchPref.setChecked(checkBox.isChecked());
    switchPref.setSummary(checkBox.getSummary());
    switchPref.setSummaryOn(checkBox.getSummaryOn());
    switchPref.setSummaryOff(checkBox.getSummaryOff());
    switchPref.setSwitchTextOn(EMPTY_TEXT);
    switchPref.setSwitchTextOff(EMPTY_TEXT);
    group.addPreference(switchPref);/*from  ww w.  j  a  va  2  s . c o m*/
    switchPref.setDependency(checkBox.getDependency());
}

From source file:de.badaix.snapcast.GroupSettingsFragment.java

public ArrayList<String> getClients() {
    ArrayList<String> clients = new ArrayList<>();
    for (int i = 0; i < prefCatClients.getPreferenceCount(); ++i) {
        CheckBoxPreference checkBoxPref = (CheckBoxPreference) prefCatClients.getPreference(i);
        if (checkBoxPref.isChecked())
            clients.add(checkBoxPref.getKey());
    }/*from  ww  w . ja  v a2  s . c  o  m*/
    return clients;
}