[ Web Proxy ]
URL:
Viewing: https://developer.android.com/develop/ui/views/components/checkbox [Back]  [Original]

Add checkboxes to your app  |  Views  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]

Add checkboxes to your app Stay organized with collections Save and categorize content based on your preferences.

Try the Compose way
Jetpack Compose is the recommended UI toolkit for Android. Learn how to add components in Compose.
Note: For a better user experience, see the Material Design Checkbox documentation.

Checkboxes let the user select one or more options from a set. Typically, you present checkbox options in a vertical list.

An image showing an example of checkboxes from material.io [An image showing an example of checkboxes from material.io] Figure 1. An example of checkboxes from Material Design Checkbox.

To create each checkbox option, create a CheckBox in your layout. Because a set of checkbox options lets the user select multiple items, each checkbox is managed separately, and you must register a click listener for each one.

Respond to click events

Begin by creating a layout with CheckBox objects in a list:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <CheckBox android:id="@+id/checkbox_meat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Meat" />
    <CheckBox android:id="@+id/checkbox_cheese"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Cheese"/>
</LinearLayout>

Once your layout is ready, head to your Activity or Fragment, find your CheckBox views, and set a change listener, as in the following example:

Kotlin

findViewById<CheckBox>(R.id.checkbox_meat)
    .setOnCheckedChangeListener { buttonView, isChecked ->
        Log.d("CHECKBOXES", "Meat is checked: $isChecked")
    }

findViewById<CheckBox>(R.id.checkbox_cheese)
    .setOnCheckedChangeListener { buttonView, isChecked ->
        Log.d("CHECKBOXES", "Cheese is checked: $isChecked")
    }

Java

findViewById<CheckBox>(R.id.checkbox_meat)
    .setOnCheckedChangeListener { buttonView, isChecked ->
        Log.d("CHECKBOXES", "Meat is checked: $isChecked");
    }

findViewById<CheckBox>(R.id.checkbox_cheese)
    .setOnCheckedChangeListener { buttonView, isChecked ->
        Log.d("CHECKBOXES", "Cheese is checked: $isChecked");
    }

The previous code prints a message in Logcat every time the checkboxes change status.

Tip: If you need to change the checkbox state yourself, use the setChecked(boolean) or toggle() method.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-05-28 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-05-28 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page