Switch Button in Android

In Android Switch is button which have only two state “ON/OFF”. Switch is mostly used in the setting UI components.

See Use of switch in my old deveice.


Switch is such a like ToggleButton in Android. Almost attribute and functionality is same as ToggleButton. But you have to note that Switch is introduced in Android 4.0 ( API 14 ) so we can only use this in API 14 or higher.

Let’s see one simple example. Create Project and set Minimum SDK 14. and then follow this code.


Now run project. Our output looks like below,


Download Project.


(Visited 497 times, 1 visits today)