'Kotlin, delete all items in list with isChecked property equal to true
New to Android dev here, and this might be very basic but I have the following data class in Kotlin
data class ABC(val: id: String, val isChecked: Boolean = false)
and the following mutable list in a separate ClassB:
ABC_multiple: MutableList<ABC>
And I have the following button in the main activity of my app:
removeButton.setOnClickListener { classb.removeId() }
I would like the button to delete all of the list items that are checked (each item that will be added to the mutablelist has its own separate isChecked property)
I cannot seem to find a way to get the isChecked property to change and verified this by adding a button to run the following code:
System.out.println(ListItem + isChecked)
Clicking shows the isChecked property does not change whether any particular item in the list is checked or unchecked
Would really appreciate any help
Solution 1:[1]
There are several ways to do that. You can check this link
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | thaovd1712 |
