Android CheckBox Control

Android CheckBox is a two-states button, which you can either check or uncheck.

Android CheckBox Control


Let’s say you want to create a form to list skills. For that you can use the Android Checkbox control. Another example, language a user is fluent in. The fluency can be in more than one language, so we’re using checkbox to select one of more options at a time.

Another example, asking users to select which sports they like, it can have one or more selections, so use CheckBox i.e. Football, Cricket, Basketball, etc.

Android CheckBox Control


Here’s a simple example showing the working on Android CheckBox on Android Studio. Here, we will be showing result of selected checkbox on button click.

If you’re beginning with Android, then learn how to run your first Android app in Android Studio.

Let’s start with the usage of Android CheckBox control.

The src\main\java\com\studyopedia\studyopediaapplication\ is a java class which sets the views. Here, we will set the View to be displayed with the setContentView.

We have 5 checkboxes here: check1, check2, check3, check4, and check5, for sports football, tennis, basketball, hockey, and cricket. We also have a TextView i.e. tv1, which prints the result on button click. The result in our example is the codes assigned to each sport by the club. Whatever the user selects, gets appended and result gets displayed in TextView tv1,


For src\main\res\layout\activity_main.xml,

We have 5 checkboxes and 3 TextView. The result gets displayed in TextView textCode


The content of \src\main\AndroidManifest.xml, provides key information of your app to the system. The system needs this to run your code,


Here’s the code for res/values/strings.xml. The app name and any hardcoded strings will be visible.


For example,

We created an AVD, so now we will run our app using the same AVD. Go to Run > Run app or press the run button or Shift + f10. This will install your app on the AVD and the following emulator with your app opens up,

Here’s the output,

Android CheckBox Control Output1

Select one of more checkbox and click the CLUB CODES button to get the codes for each sport,

Android CheckBox Control Output2

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.

For Videos, Join Our YouTube Channel: Join Now

Android RatingBar Control
Android Gravity
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading