47

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

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
David
  • 37,109
  • 32
  • 120
  • 141
  • 2
    I'd say use checkboxes for selecting multiple linked items in a list of related preferences, and switch when the item is independent from others. But that's just me. I guess in the end it comes down to what makes sense to you (and your users, of course). Good question, +1. – 2Dee Jan 20 '14 at 10:27

4 Answers4

49

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.

CzBiX
  • 72
  • 6
Kent Hawkings
  • 2,793
  • 2
  • 25
  • 30
  • 1
    It's important to note that for a set of checkboxes, an additional "submit" or "save" button is required to mark the completion. Switches however are instantaneous, with immediate effect. – Ajit Panigrahi Jan 21 '18 at 09:49
  • @AjitZero: The style guide doesn't say that, and it's not consistent with actual practice either. – mhsmith Nov 19 '18 at 17:03
7

Disclaimer I'm not UX expert.

Besides what @KentHawkings has already cited from Google's design guidelines (checkboxes for list of non-exclusive options and switch for a single option), there is a good (IMHO) use case for checkbox for a single option - when the checkbox clearly means yes/no.

Good idea for checkbox: "Show notifications" option.

Bad idea for checkbox: "Wi-Fi" option (as in Android Settings).
You could use checkbox here if this option was titled "Wi-Fi is enabled", but quite obviously "Wi-Fi" with "On/Off" switch is more concise.

Note that Play Market doesn't follow Google's own guidline - it uses checkboxes in its Settings all over the place.

Community
  • 1
  • 1
Alexander Malakhov
  • 3,383
  • 2
  • 33
  • 58
  • 3
    Google Play has a really good reason to do so, It needs to be compatible and consistent throughout all Android devices back to ancient API levels (like Android 2.3). [Switches](https://developer.android.com/reference/android/widget/Switch.html) and [switch preferences](https://developer.android.com/reference/android/preference/SwitchPreference.html) were added in API level 14] and switch preferences are not included in the support library that works on API level 9. I've found a [third-party library for that](https://github.com/yongjhih/SwitchPreferenceCompat), haven't tried it though. – prompteus Nov 19 '16 at 10:59
  • @cuddlecheek I think, there are a couple of able programmers at Google, who could weither **1.** add switches to support lib v7 or **2.** implemet switches as custom widgets inside Play app :-P – Alexander Malakhov Feb 01 '17 at 17:12
  • 2
    Of course they could do that, but I suppose Google Play app and Support library are developed by different teams. So I assume Google play team didn't bother to organize adding switches to support library v7 and probably didn't find it so important to implement it themselves. I would say that if they started to developing the app for API 14+, they would use switch in appropriate places. – prompteus Feb 01 '17 at 17:38
4

After following the Settings option in android device, my opinion for difference between checkbox and switch is that:

  1. CheckBox are usually used to mark/unmark the particular setting in the service.
  2. Switches are used to turnOn/turnOff the particular services.

Possibly, that is why checkbox are treated as subset/type of switch as they allow to mark/unmark an option within the service itself( not the entire service).

Gaurav Gupta
  • 4,586
  • 4
  • 39
  • 72
0

CheckBox means it is a toggle and only a toggle. Switches means it is a toggle and if you click the text area (title and summary) some more settings window should pop up.

Chen Hao
  • 136
  • 5