VOOZH about

URL: https://www.geeksforgeeks.org/kotlin/dynamic-checkedtextview-in-kotlin/

⇱ Dynamic CheckedTextView in Kotlin - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Dynamic CheckedTextView in Kotlin

Last Updated : 12 Jul, 2025

CheckedTextView is an extension of TextView in Android that includes a checkmark, making it function like a checkbox. It is commonly used in list views where items can be selected or toggled between checked and unchecked states. Users can tap the text to change its checked status, and the checkmark updates accordingly.

In this article, we will be discussing how to make a CheckedTextView dynamically or programmatically.

Steps of Implementation

Step 1: Create a new project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.

Step 2: Modify the activity_main.xml file

Now, we need to modify our layout. For doing so : Go to app > res > layout > activity_main.xml and paste the following code.

activity_main.xml:


Step 3: Use CheckedTextView Code in MainActivity.kt file

The final step is to code our CheckedTextView. Navigate to app > src > main > java > {package-name} > MainActivity.kt.

MainActivity.kt:

Output:

Comment
Article Tags:

Explore