![]() |
VOOZH | about |
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.
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
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:
The final step is to code our CheckedTextView. Navigate to app > src > main > java > {package-name} > MainActivity.kt.
MainActivity.kt: