Convert SparseArray as List - Android android.util

Android examples for android.util:SparseArray

Description

Convert SparseArray as List

Demo Code


//package com.java2s;
import android.util.SparseArray;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static <C> List<C> asList(SparseArray<C> sparseArray) {
        if (sparseArray == null)
            return null;
        List<C> arrayList = new ArrayList<C>(sparseArray.size());
        for (int i = 0; i < sparseArray.size(); i++)
            arrayList.add(sparseArray.valueAt(i));
        return arrayList;
    }//from  w  ww  .j  a  va2  s.  c  o m
}

Related Tutorials