CheckedTextView is used to implement checkable interface where one can tick or check the needed or required items and leave out the rest.
In this article, we will be discussing how to make a CheckedTextView dynamically or programmatically.
The first step is to make or create a project in Android Studio. Here, we will be creating a project named DynamicCheckedTextView.
For creating a new project:
- Click on File, then New => New Project
- Then, check Include Kotlin Support and click next button.
- Select minimum SDK, whatever you need.
- Select Empty activity and then click finish.
Now, we need to modify our layout. For doing so : Go to app > res > layout and paste the following code:
Modify the activity_main.xml file
Next step is to add the strings which will be displayed when we check or uncheck our CheckedTextView.
Go to res/values/strings.xml and add the following lines.
Use CheckedTextView Code in MainActivity.kt file
The final step is to code our CheckedTextView. Open app/src/main/java/yourPackageName/MainActivity.kt
Run as Emulator:
- CheckedTextView in Kotlin
- Dynamic ImageView in Kotlin
- Dynamic ScrollView in Kotlin
- Dynamic SeekBar in Kotlin
- Dynamic AutoCompleteTextView in Kotlin
- Dynamic TextSwitcher in Kotlin
- Dynamic TimePicker in Kotlin
- Dynamic Button in Kotlin
- Dynamic EditText in Kotlin
- Dynamic TextView in Kotlin
- Dynamic DatePicker in Kotlin
- Dynamic Switch in Kotlin
- Dynamic TextClock in Kotlin
- Dynamic ProgressBar in Kotlin
- Dynamic ImageButton in Kotlin
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.