How to iterate through SparseArray?

后端 未结 10 1737
野的像风
野的像风 2020-11-30 18:16

Is there a way to iterate over Java SparseArray (for Android) ? I used sparsearray to easily get values by index. I could not find one.

10条回答
  •  旧巷少年郎
    2020-11-30 18:32

    For whoever is using Kotlin, honestly the by far easiest way to iterate over a SparseArray is: Use the Kotlin extension from Anko or Android KTX! (credit to Yazazzello for pointing out Android KTX)

    Simply call forEach { i, item -> }

提交回复
热议问题