CheckedTextView in Android | AndroidMonks

CheckedTextView in Android with Example

CheckedTextView is used in order to provide Checkable interface support to TextView. According to the Google Docs, “This is useful when used in a ListView where the setChoiceMode has been set to something other thanCHOICE_MODE_NONE.”

This means that, we can make use of the CheckedTextView inside a ListView without any Choice Mode set. TextView with Choice Mode option creates a effective user experience by showing Checked Images (We will see what i mean by images below).

CheckedTextView – Basics

The CheckedTextView can be created using the CheckedTextView Tag like below. However, it is important to note that, android:checkMark attribute has to be set in order to make it as a CheckedTextView, it will work like a normal TextView otherwise.

Check the below basic implementation of Checked TextView.

    android:layout_height="wrap_content" />

Just like any other View, the default Parameters are layout_width and layout_height. It is important to note that, there is another important attribute which is the android:checkMark attribute, which takes a drawable as its value.

We will see what are the other attributes related to Checked TextView and public methods associated with it.

CheckedTextView – Layout Parameters

Some of the important Layout parameters are,

These are the specific attributes with respect to the Checked TextView. Additionally, you can make use of the attributes which is normally used along with a View. Read more about it here.

CheckedTextView – Public Methods Overview

CheckedTextView – Example Application

We have seen, all the properties related to the Checked TextView. Let us jump into creating a example Application below.

First we create a simple Layout, with a Checked TextView. On toggling this textView, we create a callback mechanism to capture the respective action.


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""

        android:text="Simple Checked TextView" />

Time for creating our Activity. This is going to be a simple process, as we will need a callback to capture the onClick and react to it.

We make use of the onClickListener() on the View (CheckedTextView) like below.

Creating the CheckedTextViewClass like below.

package com.example.baradwav.samplemy;

import android.os.Bundle;
import android.widget.CheckedTextView;
import android.view.View;
import android.widget.Toast;

public class CheckedTextViewClass extends AppCompatActivity {
    CheckedTextView checkedTextView;
    protected void onCreate(Bundle savedInstanceState) {

        checkedTextView = findViewById(;
        // Capture on click and toggle the checked TextView
        checkedTextView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                    Toast.makeText(view.getContext(),"TextView is Checked",Toast.LENGTH_SHORT).show();
                    Toast.makeText(view.getContext(),"TextView is not Checked",Toast.LENGTH_SHORT).show();


Once you are done with creating the Activity, its time to check our application. We end up with a application like below.

CheckedTextView  final Output Screen
CheckedTextView final Output Screen

Drop in any comments you have below.

“Learn and Be Curious”

Leave a Comment