Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Java by (2.6k points)
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.

1 Answer

0 votes
by (46k points)

Here's the solution you need. I hadn't accurately discerned the keyAt(index) function.

So I'll try with something like this:

for(int i = 0; i < sparseArray.size(); i++) {

   int key = sparseArray.keyAt(i);

   // get the object by the key.

   Object obj = sparseArray.get(key);

}

Related questions

Browse Categories

...