Android examples for java.lang:array convert
Convert SparseBooleanArray to the List which contains indexes whose values are true
//package com.java2s; import android.util.SparseBooleanArray; import java.util.ArrayList; import java.util.List; public class Main { /**//from ww w .j a va 2 s.c o m * Convert SparseBooleanArray to the List which contains indexes whose values are true * @param sparseCheckedArray * @return */ public static List<Integer> convertToCheckedIndexList( SparseBooleanArray sparseCheckedArray) { List<Integer> checkList = new ArrayList<>(); for (int i = 0; i < sparseCheckedArray.size(); i++) { int index = sparseCheckedArray.keyAt(i); if (sparseCheckedArray.valueAt(i)) { checkList.add(index); } } return checkList; } }