ITERATING THROUGH A SPARSE ARRAY

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
.NET  C# 
 1165  View(s)
Ratings:
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.

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: Iterating Through a Sparse Array

    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);

            }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!