Example usage for android.preference SwitchPreference setDependency

List of usage examples for android.preference SwitchPreference setDependency

Introduction

In this page you can find the example usage for android.preference SwitchPreference setDependency.

Prototype

public void setDependency(String dependencyKey) 

Source Link

Document

Sets the key of a Preference that this Preference will depend on.

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);//  w  ww.  j  av a 2 s. com
    switchPref.setDependency(checkBox.getDependency());
}