List of usage examples for android.widget AbsListView setItemChecked
public void setItemChecked(int position, boolean value)
From source file:Main.java
public static void setAbsListViewAllItemsChecked(AbsListView absListView) { int count = absListView.getCount(); for (int position = 0; position < count; ++position) { absListView.setItemChecked(position, true); }//from w ww .j a v a 2 s. co m }
From source file:com.gigathinking.simpleapplock.AppListFragment.java
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { AbsListView listView = ((AbsListView) getActivity().findViewById(R.id.lv_app_list)); int count = listView.getCount(); switch (item.getItemId()) { case R.id.delete_app: ArrayList<String> positions = new ArrayList<String>(); for (int i = 0; i < count; ++i) { if (listView.isItemChecked(i)) { positions.add(mList.get(i)); }// w w w . j a v a 2 s. co m } deleteApp(positions); mode.finish(); break; case R.id.select_all: if (!allItemsChecked) { for (int i = 0; i < count; ++i) { listView.setItemChecked(i, true); } allItemsChecked = true; } else { for (int i = 0; i < count; ++i) { listView.setItemChecked(i, false); } allItemsChecked = false; } break; } return true; }
From source file:org.getlantern.firetweet.util.Utils.java
public static void clearListViewChoices(final AbsListView view) { if (view == null) return;/*w w w. ja v a 2 s. com*/ final ListAdapter adapter = view.getAdapter(); if (adapter == null) return; view.clearChoices(); for (int i = 0, j = view.getChildCount(); i < j; i++) { view.setItemChecked(i, false); } view.post(new Runnable() { @Override public void run() { view.setChoiceMode(AbsListView.CHOICE_MODE_NONE); } }); // Workaround for Android bug // http://stackoverflow.com/questions/9754170/listview-selection-remains-persistent-after-exiting-choice-mode // final int position = view.getFirstVisiblePosition(), offset = Utils.getFirstChildOffset(view); // view.setAdapter(adapter); // Utils.scrollListToPosition(view, position, offset); }