Home > DeveloperSection > Forums > Iterating Through a Sparse Array
Ankit Singh

Total Post:341

Points:2389
Posted on    October-10-2014 11:50 PM

 .NET .NET  C# 
Ratings:


 1 Reply(s)
 824  View(s)
Rate this:

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.



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    October-10-2014 11:52 PM

seems I found the solution. I haven't properly noticed keyAt(index) function.

So I'll go with something like this

int key = 0;

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

        {

            key = sparseArray.keyAt(i);

            // get the object by the key.

            Object obj = sparseArray.get(key);

        }


Don't want to miss updates? Please click the below button!

Follow MindStick