Switch (On/Off) Tutorial With Example In Android Studio

Switch (On/Off) Tutorial With Example In Android Studio

Switch (On/Off) Tutorial With Example In Android Studio

access_time November 18, 2017 chat_bubble_outline 0 comments

Switch: Switch is a two-state toggle switch widget that can select between two options. It is used to display checked and unchecked state of a button providing slider control to user. Switch is a subclass of CompoundButton. It is basically an off/on button which indicate the current state of Switch. It is commonly used in selecting on/off in Sound, Bluetooth, WiFi etc.

Step 1: Open up Android Studio Project through res -> layout -> activity_main.xml (or) main.xml and add below code or just drag and drop the switch to design XML file.

Step 3:Add below code in MainActivity.java to handle events on switch.

 

 

content_copyCategorized under

No Comments

comment No comments yet

You can be first to leave a comment

Submit an answer

<