Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.util.SparseBooleanArray;

import android.widget.AbsListView;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List<Integer> getAbsListViewCheckedItemPositions(AbsListView absListView) {
        SparseBooleanArray checked = absListView.getCheckedItemPositions();
        List<Integer> positions = new ArrayList<>();
        int checkedSize = checked.size();
        for (int i = 0; i < checkedSize; ++i) {
            if (checked.valueAt(i)) {
                positions.add(checked.keyAt(i));
            }
        }
        return positions;
    }
}