In this tutorial, I am going to show how to use android CheckBox in android application. CheckBox is a two state button that user can select or unselect. Users can check one or more option from a set. Following is the simple steps to show and control CheckBox.
Android Example: How to use Android CheckBox
Create a new Android Project
Let’s start by creating a new android project with following information to use android CheckBox
Application Name: Android CheckBox Example
Company Domain: viralandroid.com
Package Name: com.viralandroid.androidcheckboxexample
Minimum SDK: Android 2.2 (API 8 Froyo)
XML Layout File
Following is the xml layout file with many CheckBox and added onClick attribute in all CheckBox.
Java Activity File
In java activity file we control the CheckBox select and the code looks like this.
Default content of strings.xml file
Now, run your application which looks like below.