Search code examples
androidcheckboxandroid-preferencespreferenceactivity

When to use CheckBox and when Switch


Can anyone can tell me when to use Checkbox and when Switch?

I mean, what is the real login difference between the two in the context of a PreferenceActivity?

For example, will you change the next section to Checkboxes? It's part of a set, but using a Switch here looks better.

enter image description here


Solution

  • I actually find this to be quite an interesting question, particularly considering that one can easily emulate the functionality of a switch using a checkbox in Android.

    According to the Android developers guide, a checkbox is simply a type of switch. Check the quotes below or read the full description here.

    Checkboxes: Checkboxes allow the user to select multiple options from a set. Avoid using a single checkbox to turn an option off or on. Instead, use an on/off switch.

    On/off Switches: On/off switches toggle the state of a single settings option.