drakeet / MultiType

Flexible multiple types for Android RecyclerView.
Apache License 2.0
5.76k stars 749 forks source link

How do I get the number of items of a certain type? #263

Closed cv0cv0 closed 5 years ago

cv0cv0 commented 5 years ago

如何获取某一类型的 item 数?

linzhengloser commented 5 years ago

如果你使用的是 Kotlin,可以这么写 mItems.filter { it is type }.size

drakeet commented 5 years ago

如上(感谢帮忙解答)。 或者说,你可以拿到 items 并一一取出其项目进行检查和计数。

cv0cv0 commented 5 years ago

感谢解答。

我主要是判断当前 position 是不是当前类型的最后一个,使用 getItemType(position + 1) == 1 来达到目的。