Code example for SparseBooleanArray

Methods: getkeyAtsize

0
 
            ListView lv = getListView();
            SparseBooleanArray a = lv.getCheckedItemPositions();
            int fstSelIndex = -1;
 
            if (a.get(a.keyAt(0))) {// check at leas one slected
                int[] toDelete = new int[a.size()];
                for (int i = 0; i < a.size(); i++) {
                    int key = a.keyAt(i);
                    if (a.get(key)) {
                        toDelete[i] = key;
                    } 
                } 
                doDeleteAll(toDelete);
            } else { 
                Toast t = Toast.makeText(LoadSavedPostsActivity.this, "select item to delete", 1000);
                t.show();
            } 
 
        } 
Experience pair programming with AI  Get Codota for Java