Android tutorial - Android checkbox - android app development - android studio - android development tutorial
Learn android - android tutorial - Android checkbox - android examples - android programs
Checkbox
- Alternatively referred to as a checkbox, selection box, or tick box, a check box is a square box where the user can click to say that they want or have a particular setting.
- Check boxes are used when more than one option may need to be selected.
- Checking would disable it.
- The Box would enable that option and unchecking it .
- In Android, you can use “android.widget.CheckBox” class to render a checkbox.
- In this tutorial, we show you how to create 3 checkboxes in XML file, and Demonstrates the use of listener to check the checkbox state – checked or unchecked.
Custom String
- Open “res/values/strings.xml” file, add some user-defined string.
CheckBox
- Open “res/layout/main.xml” file, add 3 “CheckBox” and a button, inside the LinearLayout.
File : res/layout/main.xml
Code
- Attach listeners inside your activity “onCreate()” method, to monitor following events :
- If checkbox id : “chkIos” is checked, display a floating box with message “Wikitechy - Android Tutorial”.
- If button is is clicked, display a floating box and display the checkbox states.
File : MyAndroidAppActivity.java
Demo - android emulator - android tutorial
- Run the application.
- Result :
- If “IPhone” is checked :
- Checked “IPhone” and “Windows Mobile”, later, click on the “display” button :