ListAdapter does not update item in RecyclerView: data changes but UI does not redraw
Hello everyone! I'm a beginner in Kotlin and Android development. I'm using ListAdapter for RecyclerView, but I've encountered a strange problem: when I change data in the list and call submitList(), the items are not updated on the screen. Here is my code:
```kotlin
data class Item(val id: Int, var title: String, var isCompleted: Boolean)
class ItemDiffCallback : DiffUtil.ItemCallback- () {
override fun areItemsTheSame(oldItem: Item, newItem: Item): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(oldItem: Item, newItem: Item): Boolean {
return oldItem == newItem
}
}
class ItemAdapter : ListAdapter
- (ItemDiffCallback()) {
// ... ViewHolder and bind
}
// In Activity
val items = mutableListOf(
Ite
No answers yet.
Log in to leave an answer
Blogs
Testing in PHP: unit, integration, e2e from A to Z
Working with WebAssembly and JavaScript: From A to Z in Node.js
Java in 2025: What Will Change and Why It's Time to Update Your Code
Move Semantics in C++: What It Is and Why a Beginner Needs It