Java Code Examples for android.widget.ListView#isItemChecked()

The following examples show how to use android.widget.ListView#isItemChecked() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private void actionModeDelete() {
    ListView lv = getListView();
    
    ArrayList<Long> checkedIds = new ArrayList<Long>();
    
    for(int i = 0; i < lv.getCount(); i++) {
        if(lv.isItemChecked(i)) {
            long[] selectedIds = mAdapter.getCallIdsAtPosition(i);
            
            for(long id : selectedIds) {
                checkedIds.add(id);
            }
            
        }
    }
    if(checkedIds.size() > 0) {
        String strCheckedIds = TextUtils.join(", ", checkedIds);
        Log.d(THIS_FILE, "Checked positions ("+ strCheckedIds +")");
        getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, Calls._ID + " IN ("+strCheckedIds+")", null);
        mMode.finish();
    }
}
 
Example 2
private void actionModeDialpad() {
    
    ListView lv = getListView();

    for(int i = 0; i < lv.getCount(); i++) {
        if(lv.isItemChecked(i)) {
            mAdapter.getItem(i);
            String number = mAdapter.getCallRemoteAtPostion(i);
            if(!TextUtils.isEmpty(number)) {
                Intent it = new Intent(Intent.ACTION_DIAL);
                it.setData(SipUri.forgeSipUri(SipManager.PROTOCOL_SIP, number));
                startActivity(it);
            }
            break;
        }
    }
    mMode.invalidate();
    
}
 
Example 3
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    ListView list = (ListView) parent;
    int lastIndex = mGrpItems.size() - 1;
    if (list.isItemChecked(lastIndex)) {
        list.setItemChecked(lastIndex, false);
        createNewGroup();
        return;
    }

    boolean checked = list.isItemChecked(position);
    mGrpItems.get(position).setChecked(checked);
    String name = mGrpItems.get(position).toString();

    if (checked) {
        mAppGroups.add(name);
    } else {
        mAppGroups.remove(name);
    }
    updateGrpButton();
}
 
Example 4
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
    Log.d(THIS_FILE, "onPrepareActionMode");
    ListView lv = getListView();
    int nbrCheckedItem = 0;

    for (int i = 0; i < lv.getCount(); i++) {
        if (lv.isItemChecked(i)) {
            nbrCheckedItem++;
        }
    }
    menu.findItem(R.id.delete).setVisible(nbrCheckedItem > 0);
    menu.findItem(R.id.dialpad).setVisible(nbrCheckedItem == 1);
    return false;
}