List of usage examples for android.widget ListView getCheckedItemCount
public int getCheckedItemCount()
From source file:org.odk.collect.android.activities.AppListActivity.java
public static void toggleButtonLabel(Button toggleButton, ListView lv) { if (lv.getCheckedItemCount() != lv.getCount()) { toggleButton.setText(R.string.select_all); } else {/*from www.ja va 2 s.c o m*/ toggleButton.setText(R.string.clear_all); } }
From source file:org.odk.collect.android.activities.AppListActivity.java
public static boolean toggleChecked(ListView lv) { // shortcut null case if (lv == null) { return false; }/*w w w.j ava 2s . c om*/ boolean newCheckState = lv.getCount() > lv.getCheckedItemCount(); setAllToCheckedState(lv, newCheckState); return newCheckState; }
From source file:com.btmura.android.reddit.app.MessageThreadListController.java
@Override public boolean onPrepareActionMode(ActionMode mode, Menu menu, ListView listView) { int count = listView.getCheckedItemCount(); int position = Views.getCheckedPosition(listView); mode.setTitle(context.getResources().getQuantityString(R.plurals.messages, count, count)); prepareReplyActionItem(menu, count, position); prepareAuthorActionItem(menu, count, position); return true;// w w w. ja va 2 s. co m }
From source file:com.btmura.android.reddit.app.SubredditActionModeController.java
@Override public boolean onPrepareActionMode(ActionMode mode, Menu menu, ListView lv) { int count = lv.getCheckedItemCount(); boolean aboutItemVisible = count == 1; boolean shareItemsVisible = count == 1; SparseBooleanArray checked = lv.getCheckedItemPositions(); int size = checked.size(); for (int i = 0; i < size; i++) { if (checked.valueAt(i)) { int position = checked.keyAt(i); String subreddit = adapter.getName(position); boolean hasSidebar = Subreddits.hasSidebar(subreddit); aboutItemVisible &= hasSidebar; shareItemsVisible &= hasSidebar; }//from ww w . ja va2 s .c o m } prepareMode(count); prepareAddItem(menu); prepareAboutItem(menu, lv, aboutItemVisible); prepareDeleteItem(menu); prepareShareItems(menu, shareItemsVisible); return true; }
From source file:com.akalipetis.action_mode_list_fragment.ActionModeListFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public int calculateCheckedItems() { ListView l = getListView(); if (Build.VERSION.SDK_INT >= 11) return l.getCheckedItemCount(); SparseBooleanArray checkedItems = l.getCheckedItemPositions(); if (checkedItems == null) return 0; int cnt = 0;/* w w w . j a va2 s.c om*/ for (int i = 0, lim = checkedItems.size(); i < lim; ++i) { int key = checkedItems.keyAt(i); if (checkedItems.get(key, false)) cnt++; } return cnt; }
From source file:com.akalipetis.fragment.ActionModeListFragment.java
public int calculateCheckedItems() { ListView l = getListView(); if (Build.VERSION.SDK_INT >= 11) return l.getCheckedItemCount(); SparseBooleanArray checkedItems = l.getCheckedItemPositions(); if (checkedItems == null) return 0; int cnt = 0;/*from w w w .j a v a2s. c om*/ for (int i = 0, lim = checkedItems.size(); i < lim; ++i) { int key = checkedItems.keyAt(i); if (checkedItems.get(key, false)) cnt++; } return cnt; }
From source file:com.btmura.android.reddit.app.SubredditActionModeController.java
private String[] getCheckedSubreddits(ListView lv) { SparseBooleanArray checked = lv.getCheckedItemPositions(); String[] subreddits = new String[lv.getCheckedItemCount()]; int size = checked.size(); int j = 0;/*from w w w . j a va 2 s. com*/ for (int i = 0; i < size; i++) { if (checked.valueAt(i)) { int position = checked.keyAt(i); subreddits[j++] = adapter.getName(position); } } return subreddits; }
From source file:com.btmura.android.reddit.app.CommentListController.java
private boolean isCheckedCount(ListView lv, int checkedItemCount) { return lv.getCheckedItemCount() == checkedItemCount; }
From source file:org.odk.collect.android.fragments.AppListFragment.java
/** * Returns the IDs of the checked items, using the ListView provided *//*from ww w . j a v a 2 s .co m*/ protected long[] getCheckedIds(ListView lv) { // This method could be simplified by using getCheckedItemIds, if one ensured that // IDs were stable? (see the getCheckedItemIds doc). int itemCount = lv.getCount(); int checkedItemCount = lv.getCheckedItemCount(); long[] checkedIds = new long[checkedItemCount]; int resultIndex = 0; for (int posIdx = 0; posIdx < itemCount; posIdx++) { if (lv.isItemChecked(posIdx)) { checkedIds[resultIndex] = lv.getItemIdAtPosition(posIdx); resultIndex++; } } return checkedIds; }
From source file:com.btmura.android.reddit.app.NavigationFragment.java
private String[] getCheckedSubreddits() { ListView lv = getListView(); SparseBooleanArray checked = lv.getCheckedItemPositions(); String[] subreddits = new String[lv.getCheckedItemCount()]; int size = checked.size(); int j = 0;/* www. j a v a2 s . co m*/ for (int i = 0; i < size; i++) { if (checked.valueAt(i)) { int position = checked.keyAt(i); int adapterPosition = mergeAdapter.getAdapterPosition(position); subreddits[j++] = subredditAdapter.getName(adapterPosition); } } return subreddits; }