List of usage examples for android.widget AbsListView getCheckedItemPositions
public SparseBooleanArray getCheckedItemPositions()
From source file:Main.java
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)); }//from w w w . j a v a 2 s. com } return positions; }
From source file:org.totschnig.myexpenses.fragment.TransactionList.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override// ww w. ja v a 2s . c o m protected void configureMenu11(Menu menu, int count, AbsListView lv) { super.configureMenu11(menu, count, lv); SparseBooleanArray checkedItemPositions = lv.getCheckedItemPositions(); boolean hasSplit = false, hasNotVoid = false; for (int i = 0; i < checkedItemPositions.size(); i++) { if (checkedItemPositions.valueAt(i) && isSplitAtPosition(checkedItemPositions.keyAt(i))) { hasSplit = true; break; } } for (int i = 0; i < checkedItemPositions.size(); i++) { if (checkedItemPositions.valueAt(i) && isVoidAtPosition(checkedItemPositions.keyAt(i))) { hasNotVoid = true; break; } } configureMenuInternal(menu, hasSplit, hasNotVoid, count); }