--ADVERTISEMENT--

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.

Related:
Android Radio Button Example
Android SeekBar Example
Android WebView Tutorial with Example

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.
res/layout/activity_main.xml

Java Activity File


In java activity file we control the CheckBox select and the code looks like this.
src/MainActivity.java

Default content of strings.xml file
res/values/strings.xml

Now, run your application which looks like below.

Output:

Android CheckBox Example

Post a Comment

Powered by Blogger.