Android Switch Button Example

In this tutorial, I am going to show how to use switch button in android application. A Switch is a two-state button through which only two states ON and OFF can be selected and it is one of the most use android user interface (UI) component in application setting. Switch button is only supported in android 4.0 and larger device. Following are the simple steps to implement Switch button in android.

Android Radio Button Example
Android SeekBar Example
Android CheckBox Example

Android Example: How to use Switch Button in Android

XML Layout File


Java Activity File


That’s all. Now, run your application which will look like output given below.

Android Switch Button Example
Switch Button in Android

UI 472238300937796478
Home item