Android CheckBox

Android CheckBox

A CheckBox is an on/off switch that can be toggled by the user. You should use check-boxes when presenting users with a group of selectable options that are not mutually exclusive.

CheckBox Attributes

Following are the important attributes related to CheckBox control. You can check Android official documentation for complete list of attributes and related methods which you can use to change these attributes are run time.

android:autoTextIf set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors.
android:drawableBottomThis is the drawable to be drawn below the text.
android:drawableRightThis is the drawable to be drawn to the right of the text.
android:editableIf set, specifies that this TextView has an input method.
android:textThis is the Text to display.


In this example i will be demonstrating how to control on CheckBox.


Let’s get start by creating a project in Eclipse IDE.

1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. (I kept my main activity name as

2. Open your your AndroidManifest.xml file and make your “MainActivity” as Launcher activity, there is no change in this manifest file.

3. Create a layout file for under res ⇒ layout folder. I named the layout file as activity_main.xml. In this layout there are two layout displaying two separated kind of checkbox.

4. Now, add the following code in In this class we displayed the selected checkbox name and it is checked or not via button click and check box clicking.

5. Run the application and you will get the output as shown in video and you are done.

Thanks. 🙂

Download Source Code


About the author

I am an Android developer for whom Android is the one and only love. I work as a freelancer which gets me and Android closer. I always love to share my learnings and love to learn from others knowledge too.

Leave a Comment

Comment (required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Name (required)
Email (required)