How to pass a payload to RecyclerView.Adapter.notifyItemChanged?

According to the RecyclerView.Adapter documentation, you can notify that an element has been modified and passed to an โ€œoptional payload objectโ€, which will then be merged and passed onBindViewHolder to allow more detailed user interface updates. However, when I actually try to name something like

notifyItemChanged(0, new Object())

Android Studio tells me that I have an additional argument - it wants me to use only notifyItemChanged(0). And looking at the source of the RecyclerView , it seems that such a method does not exist.

Is there a way to pass the payload (I have an old version of lib or something else) or incorrect documentation?

+4
source share
1 answer

I checked with an existing project and it works. Cm:

notifyItemChanged with payload

Not about sdk, I think you are using an older version of the library containing recyclerview and its adapter. This is the version I'm using in my example.

    compile 'com.android.support:recyclerview-v7:23.0.0'
+4
source

Source: https://habr.com/ru/post/1607356/


All Articles