Loading...

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.

Related:
Android Radio Button Example
Android SeekBar Example
Android CheckBox Example

Android Example: How to use Switch Button in Android


XML Layout File

res/layout/switch_button_example.xml

Java Activity File

src/MainActivity.java

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

Output:
Android Switch Button Example
Switch Button in Android

UI 472238300937796478
Home item