如何将有效负载传递给 RecyclerView.Adapter.notifyItemChanged?
How do I pass a payload to RecyclerView.Adapter.notifyItemChanged?
根据 documentation of RecyclerView.Adapter, you can notify that an item has been changed and pass in an "optional payload object" that will then be merged and passed to onBindViewHolder 允许更精细的 UI 更新。但是,当我实际尝试调用
notifyItemChanged(0, new Object())
Android Studio 通知我有一个额外的参数 - 它希望我只使用 notifyItemChanged(0)
。看看 source of RecyclerView 似乎确实不存在这样的方法。
是否真的有一种方法可以传递有效载荷(我有旧版本的库或其他东西),还是文档有误?
我检查了一个现有的项目,它可以工作。参见:
这与 sdk 无关,我猜您使用的是旧版本的库,其中包含 recyclerview 及其适配器。这就是我在示例中使用的版本。
compile 'com.android.support:recyclerview-v7:23.0.0'
根据 documentation of RecyclerView.Adapter, you can notify that an item has been changed and pass in an "optional payload object" that will then be merged and passed to onBindViewHolder 允许更精细的 UI 更新。但是,当我实际尝试调用
notifyItemChanged(0, new Object())
Android Studio 通知我有一个额外的参数 - 它希望我只使用 notifyItemChanged(0)
。看看 source of RecyclerView 似乎确实不存在这样的方法。
是否真的有一种方法可以传递有效载荷(我有旧版本的库或其他东西),还是文档有误?
我检查了一个现有的项目,它可以工作。参见:
这与 sdk 无关,我猜您使用的是旧版本的库,其中包含 recyclerview 及其适配器。这就是我在示例中使用的版本。
compile 'com.android.support:recyclerview-v7:23.0.0'