Example usage for android.widget AbsListView isItemChecked

List of usage examples for android.widget AbsListView isItemChecked

Introduction

In this page you can find the example usage for android.widget AbsListView isItemChecked.

Prototype

public boolean isItemChecked(int position) 

Source Link

Document

Returns the checked state of the specified position.

Usage

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));
            }/*from  w  ww  .  j a  v  a 2  s  .c o 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;
}